Class: ActiveCypher::ConnectionAdapters::AbstractProtocolHandler
- Inherits:
-
Object
- Object
- ActiveCypher::ConnectionAdapters::AbstractProtocolHandler
- Defined in:
- lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb
Overview
AbstractProtocolHandler Handles low‑level connection protocol things like version parsing and resetting the session state. It’s like a janitor for Bolt.
Direct Known Subclasses
MemgraphAdapter::ProtocolHandler, Neo4jAdapter::ProtocolHandler
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#server_version ⇒ Object
readonly
Returns the value of attribute server_version.
Instance Method Summary collapse
-
#extract_version(_agent) ⇒ Object
Extract the server version string from the agent header.
-
#initialize(connection) ⇒ AbstractProtocolHandler
constructor
A new instance of AbstractProtocolHandler.
-
#reset! ⇒ Object
Sends a Bolt RESET to clear the server’s mental state.
Constructor Details
#initialize(connection) ⇒ AbstractProtocolHandler
Returns a new instance of AbstractProtocolHandler.
285 286 287 288 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 285 def initialize(connection) @connection = connection @server_version = extract_version(connection.server_agent.to_s) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
283 284 285 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 283 def connection @connection end |
#server_version ⇒ Object (readonly)
Returns the value of attribute server_version.
283 284 285 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 283 def server_version @server_version end |
Instance Method Details
#extract_version(_agent) ⇒ Object
Extract the server version string from the agent header. Subclass this if you want to pretend you’re compatible.
292 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 292 def extract_version(_agent) = 'unknown' |
#reset! ⇒ Object
Sends a Bolt RESET to clear the server’s mental state. Great for when you’ve made a mess and don’t want to talk about it.
296 297 298 299 300 301 302 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 296 def reset! connection.(Bolt::Messaging::Reset.new) msg = connection. msg.is_a?(Bolt::Messaging::Success) rescue StandardError false end |