Commit 1fe3e0d4 authored by davebshow's avatar davebshow
Browse files

cleanup and name clarificataion

parent f3204153
from aiogremlin.process.traversal import TraversalStrategies
from aiogremlin.remote.remote_connection import RemoteStrategy
from aiogremlin.process.traversal import AsyncTraversalStrategies
from aiogremlin.remote.remote_connection import AsyncRemoteStrategy
from gremlin_python.process import graph_traversal, traversal
......@@ -90,10 +90,10 @@ class AsyncGraphTraversalSource(graph_traversal.GraphTraversalSource):
def withRemote(self, remote_connection):
source = self.get_graph_traversal_source()
source.traversal_strategies.add_strategies([RemoteStrategy(remote_connection)])
source.traversal_strategies.add_strategies([AsyncRemoteStrategy(remote_connection)])
return source
def get_graph_traversal_source(self):
return self.__class__(
self.graph, TraversalStrategies(self.traversal_strategies),
self.graph, AsyncTraversalStrategies(self.traversal_strategies),
traversal.Bytecode(self.bytecode))
......@@ -3,7 +3,7 @@ import asyncio
from gremlin_python.process import traversal
class TraversalStrategies(traversal.TraversalStrategies):
class AsyncTraversalStrategies(traversal.TraversalStrategies):
global_cache = {}
async def apply_strategies(self, traversal):
......
......@@ -3,8 +3,9 @@ from urllib.parse import urlparse
from aiogremlin.driver.cluster import Cluster
from gremlin_python.driver import serializer
from aiogremlin.remote.driver_remote_side_effects import RemoteTraversalSideEffects
from aiogremlin.remote.remote_connection import RemoteTraversal
from aiogremlin.remote.driver_remote_side_effects import (
AsyncRemoteTraversalSideEffects)
from gremlin_python.driver.remote_connection import RemoteTraversal
__author__ = 'David M. Brown (davebshow@gmail.com)'
......@@ -90,7 +91,7 @@ class DriverRemoteConnection:
async def submit(self, bytecode):
"""Submit bytecode to the Gremlin Server"""
result_set = await self._client.submit(bytecode)
side_effects = RemoteTraversalSideEffects(result_set.request_id,
side_effects = AsyncRemoteTraversalSideEffects(result_set.request_id,
self._client)
return RemoteTraversal(result_set, side_effects)
......
......@@ -3,7 +3,7 @@ from gremlin_python.process import traversal
class RemoteTraversalSideEffects(traversal.TraversalSideEffects):
class AsyncRemoteTraversalSideEffects(traversal.TraversalSideEffects):
def __init__(self, side_effect, client):
self._side_effect = side_effect
self._client = client
......@@ -14,7 +14,7 @@ class RemoteTraversalSideEffects(traversal.TraversalSideEffects):
async def __getitem__(self, key):
if isinstance(key, slice):
raise TypeError(
'RemoteTraversalSideEffects does not support slicing')
'AsyncRemoteTraversalSideEffects does not support slicing')
return await self.get(key)
async def keys(self):
......
from gremlin_python.process import traversal
class RemoteStrategy(traversal.TraversalStrategy):
class AsyncRemoteStrategy(traversal.TraversalStrategy):
def __init__(self, remote_connection):
self.remote_connection = remote_connection
......@@ -12,18 +12,3 @@ class RemoteStrategy(traversal.TraversalStrategy):
traversal.remote_results = remote_traversal
traversal.side_effects = remote_traversal.side_effects
traversal.traversers = remote_traversal.traversers
class RemoteTraversal(traversal.Traversal):
def __init__(self, traversers, side_effects):
super(RemoteTraversal, self).__init__(None, None, None)
self.traversers = traversers
self._side_effects = side_effects
@property
def side_effects(self):
return self._side_effects
@side_effects.setter
def side_effects(self, val):
self._side_effects = val
from aiogremlin.process import graph_traversal
from aiogremlin.process.traversal import TraversalStrategies
from aiogremlin.process.traversal import AsyncTraversalStrategies
from gremlin_python.structure import graph
......@@ -7,11 +7,12 @@ from gremlin_python.structure import graph
class Graph(graph.Graph):
def __init__(self):
if self.__class__ not in TraversalStrategies.global_cache:
TraversalStrategies.global_cache[self.__class__] = TraversalStrategies()
if self.__class__ not in AsyncTraversalStrategies.global_cache:
AsyncTraversalStrategies.global_cache[
self.__class__] = AsyncTraversalStrategies()
def traversal(self, traversal_source_class=None):
if not traversal_source_class:
traversal_source_class = graph_traversal.AsyncGraphTraversalSource
return traversal_source_class(
self, TraversalStrategies.global_cache[self.__class__])
self, AsyncTraversalStrategies.global_cache[self.__class__])
......@@ -46,7 +46,7 @@ Furthermore, it implements several convience methods - :py:meth:`toList`,
:py:class:`Traversal<gremlin_python.process.traversal.Traversal>`
also contains a reference to a
:py:class:`RemoteTraversalSideEffects<aiogremlin.remote.driver_remote_side_effects.RemoteTraversalSideEffects>`
:py:class:`AsyncRemoteTraversalSideEffects<aiogremlin.remote.driver_remote_side_effects.AsyncRemoteTraversalSideEffects>`
object that can be used to fetch side effects cached by the server (when applicable)::
>>> t = g.V().aggregate('a')
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment