aiogremlin.driver package¶
Subpackages¶
Submodules¶
aiogremlin.driver.client module¶
Client for the Tinkerpop 3 Gremlin Server.
-
class
aiogremlin.driver.client.Client(cluster, loop, *, hostname=None, aliases=None)[source]¶ Bases:
objectClient that utilizes a
Clusterto access a cluster of Gremlin Server hosts. Issues requests to hosts using a round robin strategy.Parameters: - cluster (aiogremlin.driver.cluster.Cluster) – Cluster used by client
- loop (asyncio.BaseEventLoop) –
- aliases (dict) – Optional mapping for aliases. Default is None
-
aliases¶ Read-only property
-
message_serializer¶ Read-only property
-
submit(message, bindings=None)[source]¶ coroutine Submit a script and bindings to the Gremlin Server.
Parameters: - message – Can be an instance of RequestMessage<gremlin_python.driver.request.RequestMessage> or Bytecode<gremlin_python.process.traversal.Bytecode> or a str representing a raw Gremlin script
- bindings (dict) – Optional bindings used with raw Grelmin
Returns: ResultSetobject
aiogremlin.driver.cluster module¶
-
class
aiogremlin.driver.cluster.Cluster(loop, aliases=None, **config)[source]¶ Bases:
objectA cluster of Gremlin Server hosts. This object provides the main high level interface used by the
aiogremlinmodule.Parameters: - loop (asyncio.BaseEventLoop) –
- aliases (dict) – Optional mapping for aliases. Default is None
- config – Optional cluster configuration passed as kwargs or dict
-
DEFAULT_CONFIG= {'ssl_certfile': '', 'ssl_keyfile': '', 'scheme': 'ws', 'port': 8182, 'message_serializer': 'gremlin_python.driver.serializer.GraphSONMessageSerializer', 'username': '', 'max_inflight': 64, 'min_conns': 1, 'max_conns': 4, 'password': '', 'ssl_password': '', 'provider': 'aiogremlin.driver.provider.TinkerGraph', 'max_times_acquired': 16, 'response_timeout': None, 'hosts': ['localhost']}¶
-
config¶ Read-only property.
Returns: dict containing the cluster configuration
-
config_from_file(filename)[source]¶ Load configuration from from file.
Parameters: filename (str) – Path to the configuration file.
-
config_from_json(filename)[source]¶ Load configuration from from JSON file.
Parameters: filename (str) – Path to the configuration file.
-
config_from_module(module)[source]¶ Load configuration from Python module.
Parameters: filename (str) – Path to the configuration file.
-
config_from_yaml(filename)[source]¶ Load configuration from from YAML file.
Parameters: filename (str) – Path to the configuration file.
-
connect(hostname=None, aliases=None)[source]¶ coroutine Get a connected client. Main API method.
Returns: A connected instance of Client<aiogremlin.driver.client.Client>
-
get_connection(hostname=None)[source]¶ coroutine Get connection from next available host in a round robin fashion.
Returns: Connection
-
hosts¶ Read-only property
-
classmethod
open(loop, *, aliases=None, configfile=None, **config)[source]¶ coroutine Open a cluster, connecting to all available hosts as specified in configuration.
Parameters: - loop (asyncio.BaseEventLoop) –
- aliases (dict) – Optional mapping for aliases. Default is None
- configfile (str) – Optional configuration file in .json or .yml format
- config – Optional cluster configuration passed as kwargs or dict
aiogremlin.driver.connection module¶
-
class
aiogremlin.driver.connection.Connection(url, transport, protocol, loop, username, password, max_inflight, response_timeout, message_serializer, provider)[source]¶ Bases:
objectMain classd for interacting with the Gremlin Server. Encapsulates a websocket connection. Not instantiated directly. Instead use :py:meth::Connection.open<aiogremlin.driver.connection.Connection.open>.
Parameters: - url (str) – url for host Gremlin Server
- transport (gremlin_python.driver.transport.AbstractBaseTransport) – Transport implementation
- protocol (gremlin_python.driver.protocol.AbstractBaseProtocol) – Protocol implementation
- loop (asyncio.BaseEventLoop) –
- username (str) – Username for database auth
- password (str) – Password for database auth
- max_inflight (int) – Maximum number of unprocessed requests at any one time on the connection
- response_timeout (float) – (optional) None by default
-
closed¶ Read-only property. Check if connection has been closed.
Returns: bool
-
message_serializer¶
-
classmethod
open(url, loop, *, protocol=None, transport_factory=None, ssl_context=None, username='', password='', max_inflight=64, response_timeout=None, message_serializer=<class 'gremlin_python.driver.serializer.GraphSONMessageSerializer'>, provider=<class 'aiogremlin.driver.provider.TinkerGraph'>)[source]¶ coroutine Open a connection to the Gremlin Server.
Parameters: - url (str) – url for host Gremlin Server
- loop (asyncio.BaseEventLoop) –
- protocol (gremlin_python.driver.protocol.AbstractBaseProtocol) – Protocol implementation
- transport_factory – Factory function for transports
- ssl_context (ssl.SSLContext) –
- username (str) – Username for database auth
- password (str) – Password for database auth
- max_inflight (int) – Maximum number of unprocessed requests at any one time on the connection
- response_timeout (float) – (optional) None by default
- message_serializer – Message serializer implementation
- provider – Graph provider object implementation
Returns:
-
submit(message)¶ Submit a script and bindings to the Gremlin Server
Parameters: message (RequestMessage<gremlin_python.driver.request.RequestMessage>) – Returns: ResultSetobject
-
url¶ Readonly property.
Returns: str The url association with this connection.
aiogremlin.driver.pool module¶
-
class
aiogremlin.driver.pool.ConnectionPool(url, loop, ssl_context, username, password, max_conns, min_conns, max_times_acquired, max_inflight, response_timeout, message_serializer, provider)[source]¶ Bases:
objectA pool of connections to a Gremlin Server host.
Parameters: - url (str) – url for host Gremlin Server
- loop (asyncio.BaseEventLoop) –
- ssl_context (ssl.SSLContext) –
- username (str) – Username for database auth
- password (str) – Password for database auth
- response_timeout (float) – (optional) None by default
- max_conns (int) – Maximum number of conns to a host
- min_connsd (int) – Minimum number of conns to a host
- max_times_acquired (int) – Maximum number of times a conn can be shared by multiple coroutines (clients)
- max_inflight (int) – Maximum number of unprocessed requests at any one time on the connection
-
release(conn)[source]¶ Release connection back to pool after use.
Parameters: conn (PooledConnection) –
-
url¶ Readonly property.
Returns: str
-
class
aiogremlin.driver.pool.PooledConnection(conn, pool)[source]¶ Bases:
objectWrapper for
Connectionthat helps manage tomfoolery associated with connection pooling.Parameters: - conn (aiogremlin.driver.connection.Connection) –
- pool (aiogremlin.driver.pool.ConnectionPool) –
-
closed¶ Readonly property.
Returns: bool
-
submit(message)¶ coroutine Submit a script and bindings to the Gremlin Server
Parameters: Returns: aiohttp.ClientResponseobject
-
times_acquired¶ Readonly property.
Returns: int
-
write(message)[source]¶ coroutine Submit a script and bindings to the Gremlin Server
Parameters: Returns: aiohttp.ClientResponseobject
aiogremlin.driver.protocol module¶
-
class
aiogremlin.driver.protocol.GremlinServerWSProtocol(message_serializer, username='', password='')[source]¶ Bases:
gremlin_python.driver.protocol.AbstractBaseProtocolImplemenation of the Gremlin Server Websocket protocol
aiogremlin.driver.provider module¶
-
class
aiogremlin.driver.provider.Provider[source]¶ Bases:
objectSuperclass for provider plugins
-
DEFAULT_OP_ARGS= {}¶
-
-
class
aiogremlin.driver.provider.TinkerGraph[source]¶ Bases:
aiogremlin.driver.provider.ProviderDefault provider
aiogremlin.driver.resultset module¶
aiogremlin.driver.server module¶
-
class
aiogremlin.driver.server.GremlinServer(url, loop, **config)[source]¶ Bases:
objectClass that wraps a connection pool. Currently doesn’t do much, but may be useful in the future….
Parameters: pool (pool.ConnectionPool) – -
classmethod
open(url, loop, **config)[source]¶ coroutine Establish connection pool and host to Gremlin Server.
Parameters: - url (str) – url for host Gremlin Server
- loop (asyncio.BaseEventLoop) –
- ssl_context (ssl.SSLContext) –
- username (str) – Username for database auth
- password (str) – Password for database auth
- response_timeout (float) – (optional) None by default
- max_conns (int) – Maximum number of conns to a host
- min_connsd (int) – Minimum number of conns to a host
- max_times_acquired (int) – Maximum number of times a conn can be shared by multiple coroutines (clients)
- max_inflight (int) – Maximum number of unprocessed requests at any one time on the connection
Returns:
-
pool¶ Readonly property.
Returns: ConnectionPool
-
url¶
-
classmethod