@@ -73,35 +73,13 @@ def driver(cls, uri, *, auth=None, acquire_timeout=None, **config):
7373 else :
7474 raise ValueError ("Unknown URI scheme {!r}" .format (parsed .scheme ))
7575
76- @classmethod
77- async def async_driver (cls , uri , * , auth = None , loop = None , ** config ):
78- """ Create a Neo4j driver that uses async I/O and task-based
79- concurrency.
80- """
81- parsed = urlparse (uri )
82- if parsed .scheme == "bolt" :
83- return await cls .async_bolt_driver (parsed .netloc , auth = auth , loop = loop , ** config )
84- elif parsed .scheme == "neo4j" or parsed .scheme == "bolt+routing" :
85- rc = cls ._parse_routing_context (parsed .query )
86- return await cls .async_neo4j_driver (parsed .netloc , auth = auth , routing_context = rc ,
87- loop = loop , ** config )
88- else :
89- raise ValueError ("Unknown URI scheme {!r}" .format (parsed .scheme ))
90-
9176 @classmethod
9277 def bolt_driver (cls , target , * , auth = None , acquire_timeout = None , ** config ):
9378 """ Create a driver for direct Bolt server access that uses
9479 socket I/O and thread-based concurrency.
9580 """
9681 return BoltDriver .open (target , auth = auth , acquire_timeout = acquire_timeout , ** config )
9782
98- @classmethod
99- async def async_bolt_driver (cls , target , * , auth = None , loop = None , ** config ):
100- """ Create a driver for direct Bolt server access that uses
101- async I/O and task-based concurrency.
102- """
103- return await AsyncBoltDriver .open (target , auth = auth , loop = loop , ** config )
104-
10583 @classmethod
10684 def neo4j_driver (cls , * targets , auth = None , routing_context = None , acquire_timeout = None ,
10785 ** config ):
@@ -111,13 +89,6 @@ def neo4j_driver(cls, *targets, auth=None, routing_context=None, acquire_timeout
11189 return Neo4jDriver .open (* targets , auth = auth , routing_context = routing_context ,
11290 acquire_timeout = acquire_timeout , ** config )
11391
114- @classmethod
115- async def async_neo4j_driver (cls , * targets , auth = None , loop = None , ** config ):
116- """ Create a driver for routing-capable Neo4j service access
117- that uses async I/O and task-based concurrency.
118- """
119- return await AsyncNeo4jDriver .open (* targets , auth = auth , loop = loop , ** config )
120-
12192 @classmethod
12293 def _parse_routing_context (cls , query ):
12394 """ Parse the query portion of a URI to generate a routing
@@ -254,34 +225,6 @@ def verify_connectivity(self, **config):
254225 raise NotImplementedError
255226
256227
257- class AsyncDriver :
258-
259- @classmethod
260- async def open (cls , uri , ** config ):
261- raise NotImplementedError
262-
263- def __init__ (self , pool ):
264- self ._pool = pool
265-
266- async def __aenter__ (self ):
267- return self
268-
269- async def __aexit__ (self , exc_type , exc_val , exc_tb ):
270- await self .close ()
271-
272- async def session (self , ** config ):
273- """ Create a reactive session.
274-
275- :param config: session configuration
276- (see :class:`.RxSessionConfig` for details)
277- :returns: new :class:`.RxSession` object
278- """
279- raise NotImplementedError
280-
281- async def close (self ):
282- await self ._pool .close ()
283-
284-
285228class BoltDriver (Direct , Driver ):
286229 """ A :class:`.BoltDriver` is created from a ``bolt`` URI and addresses
287230 a single database machine. This may be a standalone server or could be a
@@ -380,52 +323,3 @@ def _verify_routing_connectivity(self):
380323 if val is not None :
381324 return routing_info
382325 raise ServiceUnavailable ("Could not connect to any routing servers." )
383-
384-
385- class AsyncBoltDriver (Direct , AsyncDriver ):
386-
387- @classmethod
388- async def open (cls , target , * , auth = None , loop = None , ** config ):
389- from neo4j .aio import BoltPool
390- from neo4j .work import WorkspaceConfig
391- address = cls .parse_target (target )
392- pool_config , default_workspace_config = Config .consume_chain (config , PoolConfig ,
393- WorkspaceConfig )
394- pool = await BoltPool .open (address , auth = auth , loop = loop , ** pool_config )
395- return cls (pool , default_workspace_config )
396-
397- def __init__ (self , pool , default_workspace_config ):
398- Direct .__init__ (self , pool .address )
399- AsyncDriver .__init__ (self , pool )
400- self ._default_workspace_config = default_workspace_config
401-
402- async def session (self , ** config ):
403- from neo4j .work .aio import AsyncSession , AsyncSessionConfig
404- session_config = AsyncSessionConfig (self ._default_workspace_config ,
405- AsyncSessionConfig .consume (config ))
406- return AsyncSession (self ._pool , session_config )
407-
408-
409- class AsyncNeo4jDriver (Routing , AsyncDriver ):
410-
411- @classmethod
412- async def open (cls , * targets , auth = None , routing_context = None , loop = None , ** config ):
413- from neo4j .aio import Neo4jPool
414- from neo4j .work import WorkspaceConfig
415- addresses = cls .parse_targets (* targets )
416- pool_config , default_workspace_config = Config .consume_chain (config , PoolConfig ,
417- WorkspaceConfig )
418- pool = await Neo4jPool .open (* addresses , auth = auth , routing_context = routing_context ,
419- loop = loop , ** pool_config )
420- return cls (pool , default_workspace_config )
421-
422- def __init__ (self , pool , default_workspace_config ):
423- Routing .__init__ (self , pool .routing_table .initial_routers )
424- AsyncDriver .__init__ (self , pool )
425- self ._default_workspace_config = default_workspace_config
426-
427- async def session (self , ** config ):
428- from neo4j .work .aio import AsyncSession , AsyncSessionConfig
429- session_config = AsyncSessionConfig (self ._default_workspace_config ,
430- AsyncSessionConfig .consume (config ))
431- return AsyncSession (self ._pool , session_config )
0 commit comments