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:
object
Client that utilizes a
Cluster
to 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
-
property
aliases
¶ Read-only property
-
property
message_serializer
¶ Read-only property
aiogremlin.driver.cluster module¶
-
class
aiogremlin.driver.cluster.
Cluster
(loop, aliases=None, **config)[source]¶ Bases:
object
A cluster of Gremlin Server hosts. This object provides the main high level interface used by the
aiogremlin
module.- Parameters
loop (asyncio.BaseEventLoop) –
aliases (dict) – Optional mapping for aliases. Default is None
config – Optional cluster configuration passed as kwargs or dict
-
DEFAULT_CONFIG
= {'hosts': ['localhost'], 'max_conns': 4, 'max_inflight': 64, 'max_times_acquired': 16, 'message_serializer': 'gremlin_python.driver.serializer.GraphSONMessageSerializer', 'min_conns': 1, 'password': '', 'port': 8182, 'provider': 'aiogremlin.driver.provider.TinkerGraph', 'response_timeout': None, 'scheme': 'ws', 'ssl_certfile': '', 'ssl_keyfile': '', 'ssl_password': '', 'username': ''}¶
-
property
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.
-
async
connect
(hostname=None, aliases=None)[source]¶ coroutine Get a connected client. Main API method.
- Returns
A connected instance of Client<aiogremlin.driver.client.Client>
-
async
get_connection
(hostname=None)[source]¶ coroutine Get connection from next available host in a round robin fashion.
- Returns
-
property
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:
object
Main 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
-
property
closed
¶ Read-only property. Check if connection has been closed.
- Returns
bool
-
property
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
-
async
submit
(message)¶ Submit a script and bindings to the Gremlin Server
- Parameters
message (RequestMessage<gremlin_python.driver.request.RequestMessage>) –
- Returns
ResultSet
object
-
property
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:
object
A 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) –
-
property
url
¶ Readonly property.
- Returns
str
-
class
aiogremlin.driver.pool.
PooledConnection
(conn, pool)[source]¶ Bases:
object
Wrapper for
Connection
that helps manage tomfoolery associated with connection pooling.- Parameters
-
property
closed
¶ Readonly property.
- Returns
bool
-
async
submit
(message)¶ coroutine Submit a script and bindings to the Gremlin Server
- Parameters
- Returns
aiohttp.ClientResponse
object
-
property
times_acquired
¶ Readonly property.
- Returns
int
-
async
write
(message)[source]¶ coroutine Submit a script and bindings to the Gremlin Server
- Parameters
- Returns
aiohttp.ClientResponse
object
aiogremlin.driver.protocol module¶
-
class
aiogremlin.driver.protocol.
GremlinServerWSProtocol
(message_serializer, username='', password='')[source]¶ Bases:
gremlin_python.driver.protocol.AbstractBaseProtocol
Implemenation of the Gremlin Server Websocket protocol
aiogremlin.driver.provider module¶
-
class
aiogremlin.driver.provider.
Provider
[source]¶ Bases:
object
Superclass for provider plugins
-
DEFAULT_OP_ARGS
= {}¶
-
-
class
aiogremlin.driver.provider.
TinkerGraph
[source]¶ Bases:
aiogremlin.driver.provider.Provider
Default provider
aiogremlin.driver.resultset module¶
aiogremlin.driver.server module¶
-
class
aiogremlin.driver.server.
GremlinServer
(url, loop, **config)[source]¶ Bases:
object
Class 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
-
property
pool
¶ Readonly property.
- Returns
-
property
url
¶