Class: ActiveCypher::ConnectionAdapters::AbstractProtocolHandler

Inherits:
Object
  • Object
show all
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.


Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject (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_versionObject (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.write_message(Bolt::Messaging::Reset.new)
  msg = connection.read_message
  msg.is_a?(Bolt::Messaging::Success)
rescue StandardError
  false
end