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.
238 239 240 241 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 238 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.
236 237 238 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 236 def connection @connection end |
#server_version ⇒ Object (readonly)
Returns the value of attribute server_version.
236 237 238 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 236 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.
245 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 245 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.
249 250 251 252 253 254 255 |
# File 'lib/active_cypher/connection_adapters/abstract_bolt_adapter.rb', line 249 def reset! connection.(Bolt::Messaging::Reset.new) msg = connection. msg.is_a?(Bolt::Messaging::Success) rescue StandardError false end |