Class: Neo4j::Driver::Internal::DriverFactory
- Inherits:
-
Object
- Object
- Neo4j::Driver::Internal::DriverFactory
- Defined in:
- lib/neo4j/driver/internal/driver_factory.rb
Overview
MRI flavour of the impl-agnostic Internal::DriverFactory
seam. Owns the actual driver-construction logic — URI
validation + Internal::Driver.new(...) — so that
GraphDatabase.driver is just the convenience entry point
that wraps the user-supplied AuthToken in a
StaticAuthTokenManager and calls us.
The factory is also the single owner of the driver's non-public
extension hooks: getDomainNameResolver (nil by default = system DNS)
and create_clock (the real system clock by default). testkit's
subclass overrides them. Rather than leaking these into the
user-facing config, new_instance threads them as their own parameters
into the ConnectionProvider it assembles, so the Driver and the
user-facing config never carry them. to_domain_name_resolver is
identity (MRI doesn't bridge resolver types); to_clock wraps a
#now_millis source in Internal::ClockAdapter.
Constant Summary collapse
- VALID_SCHEMES =
%w[bolt bolt+s bolt+ssc neo4j neo4j+s neo4j+ssc].freeze
Instance Method Summary collapse
-
#create_clock ⇒ Object
The clock the driver's internals run on.
-
#getDomainNameResolver ⇒ Object
camelCase to match the name Java's DriverFactory exposes and that subclasses (testkit's DriverFactoryWithDomainNameResolver) call
superon. -
#new_instance(uri, auth_token_manager, client_certificate_manager: nil, **config) ⇒ Object
Mutual-TLS client certificates (Feature:API:SSLClientCertificate): the ClientCertificateManager is threaded into the options every connection's TlsConfig reads, so each connection's SSL context presents the current (rotatable) client certificate.
-
#to_clock(clock) ⇒ Object
Wrap a
#now_millistime source in the driver's Clock interface. - #to_domain_name_resolver(resolver_proc) ⇒ Object
Instance Method Details
#create_clock ⇒ Object
The clock the driver's internals run on. Default is the real system
clock; testkit's subclass overrides this (returning to_clock of its
own time source) so its tests can freeze/advance time — the driver
stays agnostic.
46 |
# File 'lib/neo4j/driver/internal/driver_factory.rb', line 46 def create_clock = Internal::Clock.new |
#getDomainNameResolver ⇒ Object
camelCase to match the name Java's DriverFactory exposes and that
subclasses (testkit's DriverFactoryWithDomainNameResolver) call
super on. Default: no custom resolver (system DNS is used). The
subclass returns its proc when one is registered, else falls through
to this via super.
40 |
# File 'lib/neo4j/driver/internal/driver_factory.rb', line 40 def getDomainNameResolver = nil |
#new_instance(uri, auth_token_manager, client_certificate_manager: nil, **config) ⇒ Object
Mutual-TLS client certificates (Feature:API:SSLClientCertificate): the ClientCertificateManager is threaded into the options every connection's TlsConfig reads, so each connection's SSL context presents the current (rotatable) client certificate. nil (the common case) leaves TLS unchanged.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/neo4j/driver/internal/driver_factory.rb', line 53 def new_instance(uri, auth_token_manager, client_certificate_manager: nil, **config) parsed_uri = validate_uri(uri) validate_security_settings(parsed_uri.scheme, config) config = config.merge(client_certificate_manager: client_certificate_manager) if client_certificate_manager # The factory is the single place that knows about the non-public # extension hooks (the domain-name resolver and the clock). It # assembles a fully-wired ConnectionProvider with # those baked in and hands it to the Driver, so the Driver and the # user-facing `config` never carry these hooks. # # Retain the manager (not a frozen token): the provider consults it # for the current token on every acquire and on security failures, # so token refresh / re-auth works. # # The clock the internals run on (default real, testkit's own # otherwise) is an internal extension hook like the domain-name # resolver — threaded as its own parameter to the provider / pool / # connection / routing / session, never mixed into the user-facing # `config`. clock = create_clock provider = build_connection_provider(parsed_uri, auth_token_manager, config, clock) Driver.new(uri, config, provider, clock: clock) end |
#to_clock(clock) ⇒ Object
Wrap a #now_millis time source in the driver's Clock interface. The
jruby flavour wraps it in a java.time.Clock adapter instead.
31 32 33 |
# File 'lib/neo4j/driver/internal/driver_factory.rb', line 31 def to_clock(clock) Internal::ClockAdapter.new(clock) end |
#to_domain_name_resolver(resolver_proc) ⇒ Object
25 26 27 |
# File 'lib/neo4j/driver/internal/driver_factory.rb', line 25 def to_domain_name_resolver(resolver_proc) resolver_proc end |