class Neo4j::Core::CypherSession::Adaptors::DriverRegistry

The registry is necessary due to the specs constantly creating new CypherSessions. Closing a driver is costly. Not closing it prevents the process from termination. The registry allows reusage of drivers which are thread safe and conveniently closing them in one call.

Public Class Methods

new() click to toggle source
Calls superclass method
   # File lib/neo4j/core/cypher_session/adaptors/driver.rb
21 def initialize
22   super
23   @mutex = Mutex.new
24 end

Public Instance Methods

close(driver) click to toggle source
   # File lib/neo4j/core/cypher_session/adaptors/driver.rb
38 def close(driver)
39   delete(key(driver))
40   driver.close
41 end
close_all() click to toggle source
   # File lib/neo4j/core/cypher_session/adaptors/driver.rb
43 def close_all
44   values.each(&:close)
45   clear
46 end
driver_for(url) click to toggle source
   # File lib/neo4j/core/cypher_session/adaptors/driver.rb
26 def driver_for(url)
27   uri = URI(url)
28   user = uri.user
29   password = uri.password
30   auth_token = if user
31                  Neo4j::Driver::AuthTokens.basic(user, password)
32                else
33                  Neo4j::Driver::AuthTokens.none
34                end
35   @mutex.synchronize { self[url] ||= Neo4j::Driver::GraphDatabase.driver(url, auth_token) }
36 end