def includeme(config): settings = config.registry.settings # Connection to version 6.x of ES follows # TODO The munging of these settings may change when settings refactoring complete kwargs = {} kwargs['max_retries'] = settings.get('es.client.max_retries', 3) kwargs['retry_on_timeout'] = settings.get('es.client.retry_on_timeout', False) kwargs['timeout'] = settings.get('es.client.timeout', 10) if 'es.client_poolsize' in settings: kwargs['maxsize'] = settings['es.client_poolsize'] connect(hosts=[settings['es.url']], **kwargs) # Connection to old (ES1.5) follows settings.setdefault('es.host', 'http://localhost:9200') settings.setdefault('es.index', 'hypothesis') # Add a property to all requests for easy access to the elasticsearch # client. This can be used for direct or bulk access without having to # reread the settings. config.registry['es.client'] = get_client(settings) config.add_request_method( lambda r: r.registry['es.client'], name='es', reify=True)
def test_connect_passes_hosts_and_kwargs_to_create_connection( self, connections_): hosts = ['http://localhost:9200'] kwargs = {'foo': 'bar'} connect(hosts, **kwargs) connections_.create_connection.assert_called_once_with( 'default', hosts=hosts, verify_certs=True, **kwargs)
def test_connect_passes_hosts_and_kwargs_to_create_connection(self, connections_): hosts = ['http://localhost:9200'] kwargs = { 'foo': 'bar' } connect(hosts, **kwargs) connections_.create_connection.assert_called_once_with('default', hosts=hosts, verify_certs=True, **kwargs)
def includeme(config): settings = config.registry.settings kwargs = {} kwargs['max_retries'] = settings.get('es.client.max_retries', 3) kwargs['retry_on_timeout'] = settings.get('es.client.retry_on_timeout', False) kwargs['timeout'] = settings.get('es.client.timeout', 10) if 'es.client_poolsize' in settings: kwargs['maxsize'] = settings['es.client_poolsize'] connect(hosts=[settings['es.url']], **kwargs) settings.setdefault('es.index', 'hypothesis') # Add a property to all requests for easy access to the elasticsearch 6.x # client. This can be used for direct or bulk access without having to # reread the settings. config.registry['es.client'] = get_client(settings) config.add_request_method(lambda r: r.registry['es.client'], name='es', reify=True)
def includeme(config): settings = config.registry.settings # Connection to version 6.x of ES follows # TODO The munging of these settings may change when settings refactoring complete kwargs = {} kwargs['max_retries'] = settings.get('es.client.max_retries', 3) kwargs['retry_on_timeout'] = settings.get('es.client.retry_on_timeout', False) kwargs['timeout'] = settings.get('es.client.timeout', 10) if 'es.client_poolsize' in settings: kwargs['maxsize'] = settings['es.client_poolsize'] connect(hosts=[settings['es.url']], **kwargs) # Connection to old (ES1.5) follows settings.setdefault('es.host', 'http://localhost:9200') settings.setdefault('es.index', 'hypothesis') # Add a property to all requests for easy access to the elasticsearch 1.x # client. This can be used for direct or bulk access without having to # reread the settings. config.registry['es.client'] = get_client(settings) config.add_request_method( lambda r: r.registry['es.client'], name='es', reify=True) # Add a property to all requests for easy access to the elasticsearch 6.x # client. This can be used for direct or bulk access without having to # reread the settings. config.registry['es6.client'] = get_es6_client(settings) config.add_request_method( lambda r: r.registry['es6.client'], name='es6', reify=True)
def test_connect_defaults_to_default_alias(self, connections_): connect(['http://localhost:9200']) connections_.create_connection.assert_called_once_with('default', hosts=mock.ANY, verify_certs=True)
def test_connect_defaults_to_default_alias(self, connections_): connect(['http://localhost:9200']) connections_.create_connection.assert_called_once_with( 'default', hosts=mock.ANY, verify_certs=True)