neospace 0.0.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -0
  3. data/README.md +88 -0
  4. data/ffi/bolt/address.rb +11 -0
  5. data/ffi/bolt/address_resolver.rb +12 -0
  6. data/ffi/bolt/address_set.rb +9 -0
  7. data/ffi/bolt/auth.rb +10 -0
  8. data/ffi/bolt/auto_releasable.rb +22 -0
  9. data/ffi/bolt/boolean.rb +9 -0
  10. data/ffi/bolt/bytes.rb +10 -0
  11. data/ffi/bolt/config.rb +45 -0
  12. data/ffi/bolt/connection.rb +44 -0
  13. data/ffi/bolt/connector.rb +17 -0
  14. data/ffi/bolt/dictionary.rb +15 -0
  15. data/ffi/bolt/error.rb +74 -0
  16. data/ffi/bolt/float.rb +9 -0
  17. data/ffi/bolt/integer.rb +9 -0
  18. data/ffi/bolt/library.rb +12 -0
  19. data/ffi/bolt/lifecycle.rb +9 -0
  20. data/ffi/bolt/list.rb +10 -0
  21. data/ffi/bolt/log.rb +16 -0
  22. data/ffi/bolt/socket_options.rb +14 -0
  23. data/ffi/bolt/status.rb +25 -0
  24. data/ffi/bolt/string.rb +9 -0
  25. data/ffi/bolt/structure.rb +10 -0
  26. data/ffi/bolt/value.rb +35 -0
  27. data/ffi/neo4j/driver.rb +60 -0
  28. data/ffi/neo4j/driver/access_mode.rb +10 -0
  29. data/ffi/neo4j/driver/auth_tokens.rb +18 -0
  30. data/ffi/neo4j/driver/config.rb +40 -0
  31. data/ffi/neo4j/driver/graph_database.rb +52 -0
  32. data/ffi/neo4j/driver/internal/async/access_mode_connection.rb +19 -0
  33. data/ffi/neo4j/driver/internal/async/direct_connection.rb +106 -0
  34. data/ffi/neo4j/driver/internal/bolt_server_address.rb +18 -0
  35. data/ffi/neo4j/driver/internal/bookmarks_holder.rb +30 -0
  36. data/ffi/neo4j/driver/internal/direct_connection_provider.rb +28 -0
  37. data/ffi/neo4j/driver/internal/driver_factory.rb +125 -0
  38. data/ffi/neo4j/driver/internal/error_handling.rb +108 -0
  39. data/ffi/neo4j/driver/internal/explicit_transaction.rb +146 -0
  40. data/ffi/neo4j/driver/internal/handlers/pull_all_response_handler.rb +105 -0
  41. data/ffi/neo4j/driver/internal/handlers/response_handler.rb +49 -0
  42. data/ffi/neo4j/driver/internal/handlers/run_response_handler.rb +32 -0
  43. data/ffi/neo4j/driver/internal/handlers/session_pull_all_response_handler.rb +32 -0
  44. data/ffi/neo4j/driver/internal/handlers/transaction_pull_all_response_handler.rb +23 -0
  45. data/ffi/neo4j/driver/internal/internal_driver.rb +45 -0
  46. data/ffi/neo4j/driver/internal/internal_logger.rb +32 -0
  47. data/ffi/neo4j/driver/internal/internal_record.rb +26 -0
  48. data/ffi/neo4j/driver/internal/internal_resolver.rb +31 -0
  49. data/ffi/neo4j/driver/internal/internal_statement_result.rb +52 -0
  50. data/ffi/neo4j/driver/internal/messaging/bolt_protocol.rb +24 -0
  51. data/ffi/neo4j/driver/internal/messaging/v1/bolt_protocol_v1.rb +59 -0
  52. data/ffi/neo4j/driver/internal/messaging/v2/bolt_protocol_v2.rb +16 -0
  53. data/ffi/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +63 -0
  54. data/ffi/neo4j/driver/internal/network_session.rb +129 -0
  55. data/ffi/neo4j/driver/internal/retry/exponential_backoff_retry_logic.rb +80 -0
  56. data/ffi/neo4j/driver/internal/session_factory_impl.rb +28 -0
  57. data/ffi/neo4j/driver/internal/summary/internal_result_summary.rb +67 -0
  58. data/ffi/neo4j/driver/internal/summary/internal_server_info.rb +19 -0
  59. data/ffi/neo4j/driver/internal/summary/internal_summary_counters.rb +23 -0
  60. data/ffi/neo4j/driver/internal/util/metadata_extractor.rb +15 -0
  61. data/ffi/neo4j/driver/internal/value/base_time_value.rb +22 -0
  62. data/ffi/neo4j/driver/internal/value/date_value.rb +25 -0
  63. data/ffi/neo4j/driver/internal/value/duration_value.rb +27 -0
  64. data/ffi/neo4j/driver/internal/value/local_date_time_value.rb +24 -0
  65. data/ffi/neo4j/driver/internal/value/local_time_value.rb +19 -0
  66. data/ffi/neo4j/driver/internal/value/node_value.rb +18 -0
  67. data/ffi/neo4j/driver/internal/value/offset_time_value.rb +25 -0
  68. data/ffi/neo4j/driver/internal/value/path_value.rb +41 -0
  69. data/ffi/neo4j/driver/internal/value/point2_d_value.rb +24 -0
  70. data/ffi/neo4j/driver/internal/value/point3_d_value.rb +24 -0
  71. data/ffi/neo4j/driver/internal/value/relationship_value.rb +18 -0
  72. data/ffi/neo4j/driver/internal/value/structure_value.rb +42 -0
  73. data/ffi/neo4j/driver/internal/value/time_with_zone_id_value.rb +25 -0
  74. data/ffi/neo4j/driver/internal/value/time_with_zone_offset_value.rb +28 -0
  75. data/ffi/neo4j/driver/internal/value/unbound_relationship_value.rb +18 -0
  76. data/ffi/neo4j/driver/internal/value/value_adapter.rb +99 -0
  77. data/ffi/neo4j/driver/net/server_address.rb +13 -0
  78. data/ffi/neo4j/driver/statement.rb +15 -0
  79. data/ffi/neo4j/driver/summary/statement_type.rb +14 -0
  80. data/ffi/neo4j/driver/types/entity.rb +21 -0
  81. data/ffi/neo4j/driver/types/node.rb +16 -0
  82. data/ffi/neo4j/driver/types/path.rb +35 -0
  83. data/ffi/neo4j/driver/types/relationship.rb +19 -0
  84. data/lib/loader.rb +18 -0
  85. data/lib/neo4j/driver/auto_closable.rb +32 -0
  86. data/lib/neo4j/driver/exceptions/authentication_exception.rb +10 -0
  87. data/lib/neo4j/driver/exceptions/client_exception.rb +15 -0
  88. data/lib/neo4j/driver/exceptions/database_exception.rb +10 -0
  89. data/lib/neo4j/driver/exceptions/illegal_state_exception.rb +10 -0
  90. data/lib/neo4j/driver/exceptions/neo4j_exception.rb +23 -0
  91. data/lib/neo4j/driver/exceptions/no_such_record_exception.rb +33 -0
  92. data/lib/neo4j/driver/exceptions/protocol_exception.rb +10 -0
  93. data/lib/neo4j/driver/exceptions/security_exception.rb +10 -0
  94. data/lib/neo4j/driver/exceptions/service_unavailable_exception.rb +10 -0
  95. data/lib/neo4j/driver/exceptions/session_expired_exception.rb +10 -0
  96. data/lib/neo4j/driver/exceptions/transient_exception.rb +10 -0
  97. data/lib/neo4j/driver/exceptions/untrusted_server_exception.rb +10 -0
  98. data/lib/neo4j/driver/internal/duration_normalizer.rb +46 -0
  99. data/lib/neo4j/driver/internal/ruby_signature.rb +18 -0
  100. data/lib/neo4j/driver/internal/validator.rb +28 -0
  101. data/lib/neo4j/driver/types/bytes.rb +10 -0
  102. data/lib/neo4j/driver/types/local_date_time.rb +20 -0
  103. data/lib/neo4j/driver/types/local_time.rb +19 -0
  104. data/lib/neo4j/driver/types/offset_time.rb +19 -0
  105. data/lib/neo4j/driver/types/point.rb +39 -0
  106. data/lib/neo4j/driver/types/time.rb +43 -0
  107. data/lib/neo4j/driver/version.rb +7 -0
  108. data/lib/neo4j_ruby_driver.rb +20 -0
  109. metadata +314 -12
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module Lifecycle
5
+ extend Bolt::Library
6
+ attach_function :startup, :Bolt_startup, [], :void
7
+ attach_function :shutdown, :Bolt_shutdown, [], :void
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module List
5
+ extend Bolt::Library
6
+
7
+ attach_function :resize, :BoltList_resize, %i[pointer int32], :void
8
+ attach_function :value, :BoltList_value, %i[pointer int32], :pointer
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module Log
5
+ extend Bolt::Library
6
+
7
+ callback :log_func, %i[pointer string], :void
8
+
9
+ attach_function :create, :BoltLog_create, %i[pointer], :auto_pointer
10
+ attach_function :destroy, :BoltLog_destroy, %i[pointer], :void
11
+ attach_function :set_error_func, :BoltLog_set_error_func, %i[pointer log_func], :void
12
+ attach_function :set_warning_func, :BoltLog_set_warning_func, %i[pointer log_func], :void
13
+ attach_function :set_info_func, :BoltLog_set_info_func, %i[pointer log_func], :void
14
+ attach_function :set_debug_func, :BoltLog_set_debug_func, %i[pointer log_func], :void
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module SocketOptions
5
+ extend Bolt::Library
6
+
7
+ attach_function :create, :BoltSocketOptions_create, [], :auto_pointer
8
+ attach_function :destroy, :BoltSocketOptions_destroy, [:pointer], :void
9
+ attach_function :get_connect_timeout, :BoltSocketOptions_get_connect_timeout, [:pointer], :int32_t
10
+ attach_function :set_connect_timeout, :BoltSocketOptions_set_connect_timeout, %i[pointer int32_t], :int32_t
11
+ attach_function :get_keep_alive, :BoltSocketOptions_get_keep_alive, [:pointer], :int32_t
12
+ attach_function :set_keep_alive, :BoltSocketOptions_set_keep_alive, %i[pointer int32_t], :int32_t
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module Status
5
+ extend Bolt::Library
6
+ # Not connected
7
+ BOLT_CONNECTION_STATE_DISCONNECTED = 0
8
+ # Connected but not authenticated
9
+ BOLT_CONNECTION_STATE_CONNECTED = 1
10
+ # Connected and authenticated
11
+ BOLT_CONNECTION_STATE_READY = 2
12
+ # Recoverable failure
13
+ BOLT_CONNECTION_STATE_FAILED = 3
14
+ # Unrecoverable failure
15
+ BOLT_CONNECTION_STATE_DEFUNCT = 4
16
+
17
+ typedef :int32, :bolt_connection_state
18
+
19
+ attach_function :create, :BoltStatus_create, [], :auto_pointer
20
+ attach_function :destroy, :BoltStatus_destroy, [:pointer], :void
21
+ attach_function :get_state, :BoltStatus_get_state, [:pointer], :bolt_connection_state
22
+ attach_function :get_error, :BoltStatus_get_error, [:pointer], :int32
23
+ attach_function :get_error_context, :BoltStatus_get_error_context, [:pointer], :string
24
+ end
25
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module String
5
+ extend Bolt::Library
6
+
7
+ attach_function :get, :BoltString_get, [:pointer], :pointer
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module Structure
5
+ extend Bolt::Library
6
+
7
+ attach_function :code, :BoltStructure_code, %i[pointer], :int16
8
+ attach_function :value, :BoltStructure_value, %i[pointer int32], :pointer
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bolt
4
+ module Value
5
+ extend Bolt::Library
6
+
7
+ enum :bolt_type,
8
+ %i[bolt_null
9
+ bolt_boolean
10
+ bolt_integer
11
+ bolt_float
12
+ bolt_string
13
+ bolt_dictionary
14
+ bolt_list
15
+ bolt_bytes
16
+ bolt_structure]
17
+
18
+ attach_function :create, :BoltValue_create, [], :auto_pointer
19
+ attach_function :destroy, :BoltValue_destroy, %i[pointer], :void
20
+ attach_function :duplicate, :BoltValue_duplicate, %i[pointer], :auto_pointer
21
+ attach_function :copy, :BoltValue_copy, %i[pointer pointer], :void
22
+ attach_function :size, :BoltValue_size, %i[pointer], :int32
23
+ attach_function :type, :BoltValue_type, %i[pointer], :bolt_type
24
+ attach_function :to_string, :BoltValue_to_string, %i[pointer pointer int32 pointer], :int32
25
+ attach_function :format_as_null, :BoltValue_format_as_Null, %i[pointer], :void
26
+ attach_function :format_as_boolean, :BoltValue_format_as_Boolean, %i[pointer char], :void
27
+ attach_function :format_as_integer, :BoltValue_format_as_Integer, %i[pointer int64], :void
28
+ attach_function :format_as_float, :BoltValue_format_as_Float, %i[pointer double], :void
29
+ attach_function :format_as_string, :BoltValue_format_as_String, %i[pointer string int32], :void
30
+ attach_function :format_as_dictionary, :BoltValue_format_as_Dictionary, %i[pointer int32], :void
31
+ attach_function :format_as_list, :BoltValue_format_as_List, %i[pointer int32], :void
32
+ attach_function :format_as_bytes, :BoltValue_format_as_Bytes, %i[pointer pointer int32], :void
33
+ attach_function :format_as_structure, :BoltValue_format_as_Structure, %i[pointer int16 int32], :void
34
+ end
35
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Workaround for missing zeitwerk support in jruby-9.2.8.0
4
+ if RUBY_PLATFORM.match?(/java/)
5
+ module Bolt
6
+ end
7
+ module Neo4j
8
+ module Driver
9
+ module Internal
10
+ module Async
11
+ end
12
+ module Handlers
13
+ end
14
+ module Messaging
15
+ module V1
16
+ end
17
+ module V2
18
+ end
19
+ module V3
20
+ end
21
+ end
22
+ module Retry
23
+ end
24
+ module Summary
25
+ end
26
+ module Util
27
+ end
28
+ module Value
29
+ end
30
+ end
31
+ module Net
32
+ end
33
+ module Summary
34
+ end
35
+ module Types
36
+ end
37
+ end
38
+ end
39
+ end
40
+ # End workaround
41
+
42
+ require 'active_support/concern'
43
+ require 'active_support/core_ext/array/grouping'
44
+ require 'concurrent/atomic/atomic_boolean'
45
+ require 'concurrent/atomic/atomic_reference'
46
+ require 'ffi'
47
+ require 'fiddle'
48
+ require 'loader'
49
+ require 'recursive-open-struct'
50
+
51
+ module Neo4j
52
+ module Driver
53
+ end
54
+ end
55
+
56
+ Loader.load
57
+
58
+ Neo4j::Driver::Record = Neo4j::Driver::Internal::InternalRecord
59
+ Neo4j::Driver::StatementResult = Neo4j::Driver::Internal::InternalStatementResult
60
+ Neo4j::Driver::Transaction = Neo4j::Driver::Internal::ExplicitTransaction
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module AccessMode
6
+ WRITE = 0
7
+ READ = 1
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ class AuthTokens
6
+ class << self
7
+ def basic(username, password)
8
+ Internal::Validator.require_non_nil_credentials!(username, password)
9
+ Bolt::Auth.basic(username, password, nil)
10
+ end
11
+
12
+ def none
13
+ Bolt::Auth.none
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ class Config < Hash
6
+ class TrustStrategy
7
+ class << self
8
+ def trust_all_certificates; end
9
+ end
10
+ end
11
+
12
+ class << self
13
+ # How can following Java config options be expressed in seabolt:
14
+ # withLeakedSessionsLogging
15
+ # withConnectionLivenessCheckTimeout
16
+ # withTrustStrategy TRUST_ALL_CERTIFICATES, TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, TRUST_SYSTEM_CA_SIGNED_CERTIFICATE
17
+ # and in the reverse what those seabolt options correspond to in java:
18
+ # BoltConfig_set_user_agent
19
+
20
+ def default_config
21
+ {
22
+ logger: ActiveSupport::Logger.new(STDOUT, level: ::Logger::ERROR), # :set_log
23
+ leaked_session_logging: false,
24
+ #connection_liveness_check_timeout: -1, # Not configured
25
+ max_connection_lifetime: 1.hour, # :set_max_connection_life_time
26
+ max_connection_pool_size: 100, #:set_max_pool_size
27
+ connection_acquisition_timeout: 1.minute, #:set_max_connection_acquisition_time
28
+ encryption: true, # :set_transport
29
+ trust_strategy: :trust_all_certificates,
30
+ connection_timeout: 30.seconds, # BoltSocketOptions_set_connect_timeout
31
+ max_transaction_retry_time: Internal::Retry::ExponentialBackoffRetryLogic::DEFAULT_MAX_RETRY_TIME,
32
+ #resolver: nil # :set_address_resolver
33
+ keep_alive: true, # BoltSocketOptions_set_keep_alive
34
+ # ???? BoltConfig_set_user_agent
35
+ }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ class GraphDatabase
6
+ VALID_ROUTING_SCHEMES =
7
+ [Internal::DriverFactory::BOLT_ROUTING_URI_SCHEME, Internal::DriverFactory::NEO4J_URI_SCHEME].freeze
8
+
9
+ Bolt::Lifecycle.startup
10
+
11
+ at_exit do
12
+ Bolt::Lifecycle.shutdown
13
+ end
14
+
15
+ class << self
16
+ extend AutoClosable
17
+
18
+ auto_closable :driver, :routing_driver
19
+
20
+ def driver(uri, auth_token = Neo4j::Driver::AuthTokens.none, config = nil)
21
+ unless auth_token.is_a? FFI::Pointer
22
+ raise Exceptions::AuthenticationException, 'Unsupported authentication token'
23
+ end
24
+ config = Config.default_config.merge(config || {})
25
+
26
+ Internal::DriverFactory.new.new_instance(uri, auth_token, config)
27
+ end
28
+
29
+ def routing_driver(routing_uris, auth_toke, config)
30
+ assert_routing_uris(routing_uris)
31
+
32
+ routing_uris.each do |uri|
33
+ return driver(uri, auth_toke, config)
34
+ rescue Exceptions::ServiceUnavailableException => e
35
+ # log.warn("Unable to create routing driver for URI: #{uri}", e)
36
+ end
37
+
38
+ raise Exceptions::ServiceUnavailableException, 'Failed to discover an available server'
39
+ end
40
+
41
+ private
42
+
43
+ def assert_routing_uris(uris)
44
+ scheme = (uris.map(&method(:URI)).map(&:scheme) - VALID_ROUTING_SCHEMES).first
45
+ return unless scheme
46
+ raise ArgumentError,
47
+ "Illegal URI scheme, expected URI scheme '#{scheme}' to be among '[#{VALID_ROUTING_SCHEMES.join ', '}]'"
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Internal
6
+ module Async
7
+ class AccessModeConnection
8
+ attr_reader :connection, :mode
9
+ delegate :open?, :protocol, :release, :reset, :write_and_flush, to: :connection
10
+
11
+ def initialize(connection, mode)
12
+ @connection = connection
13
+ @mode = mode
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j
4
+ module Driver
5
+ module Internal
6
+ module Async
7
+ class DirectConnection
8
+ include ErrorHandling
9
+
10
+ attr_reader :protocol
11
+ attr_reader :bolt_connection
12
+
13
+ def initialize(connector, mode, config)
14
+ @connector = connector
15
+ @config = config
16
+ @bolt_connection = with_status { |status| Bolt::Connector.acquire(@connector, mode, status) }
17
+
18
+ # @protocol = Messaging::BoltProtocol.for_version(Bolt::Connection.server(bolt_connection).first)
19
+ @protocol = Messaging::BoltProtocol.for_version(3)
20
+ @status = Concurrent::AtomicReference.new(:open)
21
+ end
22
+
23
+ def write_and_flush(statement, parameters, boomarks_holder, config, run_handler, pull_handler)
24
+ check_error Bolt::Connection.clear_run(bolt_connection)
25
+ check_error Bolt::Connection.set_run_cypher(bolt_connection, statement, statement.size, parameters.size)
26
+ parameters.each_with_index do |(name, object), index|
27
+ name = name.to_s
28
+ Value::ValueAdapter.to_neo(
29
+ Bolt::Connection.set_run_cypher_parameter(bolt_connection, index, name, name.size), object
30
+ )
31
+ end
32
+ set_bookmarks(:set_run_bookmarks, boomarks_holder.bookmarks)
33
+ set_config(:set_run, config)
34
+ register(run_handler, Bolt::Connection.load_run_request(bolt_connection))
35
+ register(pull_handler, Bolt::Connection.load_pull_request(bolt_connection, -1))
36
+ flush
37
+ end
38
+
39
+ def flush
40
+ check_error Bolt::Connection.flush(bolt_connection)
41
+ end
42
+
43
+ def begin(bookmarks, config, begin_handler)
44
+ check_error Bolt::Connection.clear_begin(bolt_connection)
45
+ set_bookmarks(:set_begin_bookmarks, bookmarks)
46
+ set_config(:set_begin, config)
47
+ register(begin_handler, Bolt::Connection.load_begin_request(bolt_connection))
48
+ end
49
+
50
+ def commit(handler)
51
+ register(handler, Bolt::Connection.load_commit_request(bolt_connection))
52
+ flush
53
+ end
54
+
55
+ def rollback(handler)
56
+ register(handler, Bolt::Connection.load_rollback_request(bolt_connection))
57
+ flush
58
+ end
59
+
60
+ def release
61
+ return unless @status.compare_and_set(:open, :terminated)
62
+ Bolt::Connector.release(@connector, bolt_connection)
63
+ @bolt_connection = nil
64
+ end
65
+
66
+ def open?
67
+ @status.get == :open
68
+ end
69
+
70
+ def last_bookmark
71
+ Bolt::Connection.last_bookmark(bolt_connection).first.force_encoding(Encoding::UTF_8)
72
+ end
73
+
74
+ private
75
+
76
+ def register(handler, error_code)
77
+ check_error(error_code)
78
+ handler.request = Bolt::Connection.last_request(bolt_connection)
79
+ end
80
+
81
+ def set_bookmarks(method, bookmarks)
82
+ return unless bookmarks.present?
83
+ value = Bolt::Value.create
84
+ Value::ValueAdapter.to_neo(value, bookmarks)
85
+ check_error Bolt::Connection.send(method, bolt_connection, value)
86
+ end
87
+
88
+ def set_config(method_prefix, config)
89
+ return unless config
90
+ config.each do |key, value|
91
+ case key
92
+ when :timeout
93
+ check_error Bolt::Connection.send("#{method_prefix}_tx_timeout", bolt_connection,
94
+ DurationNormalizer.milliseconds(value))
95
+ when :metadata
96
+ bolt_value = Bolt::Value.create
97
+ Value::ValueAdapter.to_neo(bolt_value, value)
98
+ check_error Bolt::Connection.send("#{method_prefix}_tx_metadata", bolt_connection, bolt_value)
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end