pandagg.connections module

class pandagg.connections.Connections[source]

Bases: object

Class responsible for holding connections to different clusters. Used as a singleton in this module.

add_connection(alias, conn)[source]

Add a connection object, it will be passed through as-is.

configure(**kwargs)[source]

Configure multiple connections at once, useful for passing in config dictionaries obtained from other sources, like Django’s settings or a configuration management tool.

Example:

connections.configure(
    default={'hosts': 'localhost'},
    dev={'hosts': ['esdev1.example.com:9200'], 'sniff_on_start': True},
)

Connections will only be constructed lazily when requested through get_connection.

create_connection(alias='default', **kwargs)[source]

Construct an instance of elasticsearch.Elasticsearch and register it under given alias.

get_connection(alias='default')[source]

Retrieve a connection, construct it if necessary (only configuration was passed to us). If a non-string alias has been passed through we assume it’s already a client instance and will just return it as-is.

Raises KeyError if no client (or its definition) is registered under the alias.

remove_connection(alias)[source]

Remove connection from the registry. Raises KeyError if connection wasn’t found.