neo4j-ruby-driver 1.7.6 → 4.4.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (339) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -43
  3. data/lib/loader.rb +5 -3
  4. data/lib/neo4j/driver/auto_closable.rb +2 -2
  5. data/lib/neo4j/driver/exceptions/authentication_exception.rb +6 -1
  6. data/lib/neo4j/driver/exceptions/authorization_expired_exception.rb +14 -0
  7. data/lib/neo4j/driver/{types/bytes.rb → exceptions/certificate_exception.rb} +2 -2
  8. data/lib/neo4j/driver/exceptions/client_exception.rb +3 -0
  9. data/lib/neo4j/driver/exceptions/connection_read_timeout_exception.rb +14 -0
  10. data/lib/neo4j/driver/exceptions/database_exception.rb +3 -0
  11. data/lib/neo4j/driver/exceptions/discovery_exception.rb +16 -0
  12. data/lib/neo4j/driver/exceptions/fatal_discovery_exception.rb +13 -0
  13. data/lib/neo4j/driver/exceptions/protocol_exception.rb +7 -0
  14. data/lib/neo4j/driver/exceptions/result_consumed_exception.rb +13 -0
  15. data/lib/neo4j/driver/exceptions/security_exception.rb +5 -1
  16. data/lib/neo4j/driver/exceptions/service_unavailable_exception.rb +2 -0
  17. data/lib/neo4j/driver/exceptions/session_expired_exception.rb +4 -0
  18. data/lib/neo4j/driver/exceptions/token_expired_exception.rb +15 -0
  19. data/lib/neo4j/driver/exceptions/transaction_nesting_exception.rb +11 -0
  20. data/lib/neo4j/driver/exceptions/transient_exception.rb +3 -0
  21. data/lib/neo4j/driver/exceptions/untrusted_server_exception.rb +1 -0
  22. data/lib/neo4j/driver/exceptions/value/lossy_coercion.rb +15 -0
  23. data/lib/neo4j/driver/exceptions/value/not_multi_valued.rb +13 -0
  24. data/lib/neo4j/driver/exceptions/value/uncoercible.rb +15 -0
  25. data/lib/neo4j/driver/exceptions/value/unsizable.rb +12 -0
  26. data/lib/neo4j/driver/exceptions/value/value_exception.rb +12 -0
  27. data/lib/neo4j/driver/internal/bolt_server_address.rb +97 -0
  28. data/lib/neo4j/driver/internal/duration_normalizer.rb +1 -1
  29. data/lib/neo4j/driver/internal/validator.rb +5 -4
  30. data/{ffi/neo4j/driver/summary/statement_type.rb → lib/neo4j/driver/summary/query_type.rb} +1 -3
  31. data/lib/neo4j/driver/synchronizable.rb +23 -0
  32. data/lib/neo4j_ruby_driver.rb +5 -11
  33. data/{ffi → ruby}/neo4j/driver/access_mode.rb +2 -2
  34. data/ruby/neo4j/driver/auth_tokens.rb +34 -0
  35. data/ruby/neo4j/driver/bookmark.rb +21 -0
  36. data/ruby/neo4j/driver/config.rb +89 -0
  37. data/ruby/neo4j/driver/graph_database.rb +80 -0
  38. data/ruby/neo4j/driver/internal/async/connection/bolt_protocol_util.rb +51 -0
  39. data/ruby/neo4j/driver/internal/async/connection/bootstrap_factory.rb +22 -0
  40. data/ruby/neo4j/driver/internal/async/connection/channel_attributes.rb +31 -0
  41. data/ruby/neo4j/driver/internal/async/connection/channel_connected_listener.rb +32 -0
  42. data/ruby/neo4j/driver/internal/async/connection/channel_connector_impl.rb +83 -0
  43. data/ruby/neo4j/driver/internal/async/connection/channel_pipeline_builder_impl.rb +22 -0
  44. data/ruby/neo4j/driver/internal/async/connection/direct_connection.rb +30 -0
  45. data/ruby/neo4j/driver/internal/async/connection/event_loop_group_factory.rb +83 -0
  46. data/ruby/neo4j/driver/internal/async/connection/handshake_completed_listener.rb +27 -0
  47. data/ruby/neo4j/driver/internal/async/connection/handshake_handler.rb +113 -0
  48. data/ruby/neo4j/driver/internal/async/connection/netty_channel_initializer.rb +57 -0
  49. data/ruby/neo4j/driver/internal/async/connection/netty_domain_name_resolver.rb +26 -0
  50. data/ruby/neo4j/driver/internal/async/connection/netty_domain_name_resolver_group.rb +19 -0
  51. data/ruby/neo4j/driver/internal/async/connection/routing_connection.rb +36 -0
  52. data/ruby/neo4j/driver/internal/async/connection/stream.rb +12 -0
  53. data/ruby/neo4j/driver/internal/async/connection/stream_reader.rb +16 -0
  54. data/ruby/neo4j/driver/internal/async/connection_context.rb +10 -0
  55. data/ruby/neo4j/driver/internal/async/immutable_connection_context.rb +24 -0
  56. data/ruby/neo4j/driver/internal/async/inbound/byte_buf_input.rb +30 -0
  57. data/ruby/neo4j/driver/internal/async/inbound/channel_error_handler.rb +77 -0
  58. data/ruby/neo4j/driver/internal/async/inbound/chunk_decoder.rb +41 -0
  59. data/ruby/neo4j/driver/internal/async/inbound/connect_timeout_handler.rb +32 -0
  60. data/ruby/neo4j/driver/internal/async/inbound/connection_read_timeout_handler.rb +17 -0
  61. data/ruby/neo4j/driver/internal/async/inbound/inbound_message_dispatcher.rb +172 -0
  62. data/ruby/neo4j/driver/internal/async/inbound/inbound_message_handler.rb +42 -0
  63. data/ruby/neo4j/driver/internal/async/inbound/message_decoder.rb +51 -0
  64. data/ruby/neo4j/driver/internal/async/internal_async_session.rb +98 -0
  65. data/ruby/neo4j/driver/internal/async/internal_async_transaction.rb +13 -0
  66. data/ruby/neo4j/driver/internal/async/leak_logging_network_session.rb +34 -0
  67. data/ruby/neo4j/driver/internal/async/network_connection.rb +196 -0
  68. data/ruby/neo4j/driver/internal/async/network_session.rb +152 -0
  69. data/ruby/neo4j/driver/internal/async/outbound/chunk_aware_byte_buf_output.rb +110 -0
  70. data/ruby/neo4j/driver/internal/async/outbound/outbound_message_handler.rb +39 -0
  71. data/ruby/neo4j/driver/internal/async/pool/channel.rb +63 -0
  72. data/ruby/neo4j/driver/internal/async/pool/connection_pool_impl.rb +149 -0
  73. data/ruby/neo4j/driver/internal/async/pool/controller.rb +25 -0
  74. data/ruby/neo4j/driver/internal/async/pool/netty_channel_health_checker.rb +87 -0
  75. data/ruby/neo4j/driver/internal/async/pool/netty_channel_pool.rb +52 -0
  76. data/ruby/neo4j/driver/internal/async/pool/netty_channel_tracker.rb +137 -0
  77. data/ruby/neo4j/driver/internal/async/pool/network_connection_factory.rb +21 -0
  78. data/ruby/neo4j/driver/internal/async/pool/pool_settings.rb +34 -0
  79. data/ruby/neo4j/driver/internal/async/result_cursors_holder.rb +17 -0
  80. data/ruby/neo4j/driver/internal/async/unmanaged_transaction.rb +214 -0
  81. data/ruby/neo4j/driver/internal/bookmark_holder.rb +9 -0
  82. data/ruby/neo4j/driver/internal/cluster/cluster_composition.rb +58 -0
  83. data/ruby/neo4j/driver/internal/cluster/cluster_composition_lookup_result.rb +14 -0
  84. data/ruby/neo4j/driver/internal/cluster/cluster_routing_table.rb +139 -0
  85. data/ruby/neo4j/driver/internal/cluster/identity_resolver.rb +13 -0
  86. data/ruby/neo4j/driver/internal/cluster/loadbalancing/least_connected_load_balancing_strategy.rb +68 -0
  87. data/ruby/neo4j/driver/internal/cluster/loadbalancing/load_balancer.rb +159 -0
  88. data/ruby/neo4j/driver/internal/cluster/loadbalancing/round_robin_array_index.rb +13 -0
  89. data/ruby/neo4j/driver/internal/cluster/multi_databases_routing_procedure_runner.rb +34 -0
  90. data/ruby/neo4j/driver/internal/cluster/rediscovery_impl.rb +238 -0
  91. data/ruby/neo4j/driver/internal/cluster/route_message_routing_procedure_runner.rb +43 -0
  92. data/ruby/neo4j/driver/internal/cluster/routing_context.rb +77 -0
  93. data/ruby/neo4j/driver/internal/cluster/routing_procedure_cluster_composition_provider.rb +64 -0
  94. data/ruby/neo4j/driver/internal/cluster/routing_procedure_response.rb +19 -0
  95. data/ruby/neo4j/driver/internal/cluster/routing_settings.rb +24 -0
  96. data/ruby/neo4j/driver/internal/cluster/routing_table_handler_impl.rb +116 -0
  97. data/ruby/neo4j/driver/internal/cluster/routing_table_registry_impl.rb +140 -0
  98. data/ruby/neo4j/driver/internal/cluster/single_database_routing_procedure_runner.rb +76 -0
  99. data/ruby/neo4j/driver/internal/connection_settings.rb +16 -0
  100. data/ruby/neo4j/driver/internal/cursor/async_result_cursor_impl.rb +68 -0
  101. data/ruby/neo4j/driver/internal/cursor/async_result_cursor_only_factory.rb +28 -0
  102. data/ruby/neo4j/driver/internal/cursor/disposable_async_result_cursor.rb +59 -0
  103. data/ruby/neo4j/driver/internal/cursor/result_cursor_factory_impl.rb +29 -0
  104. data/ruby/neo4j/driver/internal/cursor/rx_result_cursor_impl.rb +110 -0
  105. data/ruby/neo4j/driver/internal/database_name.rb +12 -0
  106. data/ruby/neo4j/driver/internal/database_name_util.rb +37 -0
  107. data/ruby/neo4j/driver/internal/default_bookmark_holder.rb +15 -0
  108. data/ruby/neo4j/driver/internal/default_domain_name_resolver.rb +11 -0
  109. data/ruby/neo4j/driver/internal/direct_connection_provider.rb +40 -0
  110. data/ruby/neo4j/driver/internal/driver_factory.rb +126 -0
  111. data/ruby/neo4j/driver/internal/handlers/begin_tx_response_handler.rb +20 -0
  112. data/ruby/neo4j/driver/internal/handlers/channel_releasing_reset_response_handler.rb +29 -0
  113. data/ruby/neo4j/driver/internal/handlers/commit_tx_response_handler.rb +25 -0
  114. data/ruby/neo4j/driver/internal/handlers/hello_response_handler.rb +65 -0
  115. data/ruby/neo4j/driver/internal/handlers/init_response_handler.rb +34 -0
  116. data/ruby/neo4j/driver/internal/handlers/legacy_pull_all_response_handler.rb +228 -0
  117. data/ruby/neo4j/driver/internal/handlers/no_op_response_handler.rb +16 -0
  118. data/ruby/neo4j/driver/internal/handlers/ping_response_handler.rb +29 -0
  119. data/ruby/neo4j/driver/internal/handlers/pull_handlers.rb +32 -0
  120. data/ruby/neo4j/driver/internal/handlers/pulln/auto_pull_response_handler.rb +178 -0
  121. data/ruby/neo4j/driver/internal/handlers/pulln/basic_pull_response_handler.rb +288 -0
  122. data/ruby/neo4j/driver/internal/handlers/pulln/fetch_size_util.rb +20 -0
  123. data/ruby/neo4j/driver/internal/handlers/reset_response_handler.rb +34 -0
  124. data/ruby/neo4j/driver/internal/handlers/rollback_tx_response_handler.rb +19 -0
  125. data/ruby/neo4j/driver/internal/handlers/route_message_response_handler.rb +21 -0
  126. data/ruby/neo4j/driver/internal/handlers/routing_response_handler.rb +70 -0
  127. data/ruby/neo4j/driver/internal/handlers/run_response_handler.rb +38 -0
  128. data/ruby/neo4j/driver/internal/handlers/session_pull_response_completion_listener.rb +34 -0
  129. data/ruby/neo4j/driver/internal/handlers/transaction_pull_response_completion_listener.rb +20 -0
  130. data/ruby/neo4j/driver/internal/impersonation_util.rb +22 -0
  131. data/ruby/neo4j/driver/internal/internal_bookmark.rb +38 -0
  132. data/ruby/neo4j/driver/internal/internal_database_name.rb +11 -0
  133. data/ruby/neo4j/driver/internal/internal_driver.rb +78 -0
  134. data/ruby/neo4j/driver/internal/internal_entity.rb +22 -0
  135. data/ruby/neo4j/driver/internal/internal_node.rb +21 -0
  136. data/ruby/neo4j/driver/internal/internal_pair.rb +9 -0
  137. data/ruby/neo4j/driver/internal/internal_path.rb +35 -0
  138. data/ruby/neo4j/driver/internal/internal_point2_d.rb +9 -0
  139. data/ruby/neo4j/driver/internal/internal_point3_d.rb +6 -0
  140. data/{ffi → ruby}/neo4j/driver/internal/internal_record.rb +2 -1
  141. data/ruby/neo4j/driver/internal/internal_relationship.rb +26 -0
  142. data/ruby/neo4j/driver/internal/internal_result.rb +60 -0
  143. data/ruby/neo4j/driver/internal/internal_session.rb +81 -0
  144. data/ruby/neo4j/driver/internal/internal_transaction.rb +48 -0
  145. data/ruby/neo4j/driver/internal/logging/channel_activity_logger.rb +29 -0
  146. data/ruby/neo4j/driver/internal/logging/channel_error_logger.rb +17 -0
  147. data/ruby/neo4j/driver/internal/logging/prefixed_logger.rb +19 -0
  148. data/ruby/neo4j/driver/internal/logging/reformatted_logger.rb +17 -0
  149. data/ruby/neo4j/driver/internal/messaging/abstract_message_writer.rb +23 -0
  150. data/ruby/neo4j/driver/internal/messaging/bolt_protocol.rb +30 -0
  151. data/ruby/neo4j/driver/internal/messaging/bolt_protocol_version.rb +46 -0
  152. data/ruby/neo4j/driver/internal/messaging/common/common_message_reader.rb +51 -0
  153. data/ruby/neo4j/driver/internal/messaging/common/common_value.rb +31 -0
  154. data/ruby/neo4j/driver/internal/messaging/common/common_value_packer.rb +101 -0
  155. data/ruby/neo4j/driver/internal/messaging/common/common_value_unpacker.rb +234 -0
  156. data/ruby/neo4j/driver/internal/messaging/encode/begin_message_encoder.rb +15 -0
  157. data/ruby/neo4j/driver/internal/messaging/encode/commit_message_encoder.rb +14 -0
  158. data/ruby/neo4j/driver/internal/messaging/encode/discard_all_message_encoder.rb +14 -0
  159. data/ruby/neo4j/driver/internal/messaging/encode/discard_message_encoder.rb +15 -0
  160. data/ruby/neo4j/driver/internal/messaging/encode/goodbye_message_encoder.rb +14 -0
  161. data/ruby/neo4j/driver/internal/messaging/encode/hello_message_encoder.rb +15 -0
  162. data/ruby/neo4j/driver/internal/messaging/encode/init_message_encoder.rb +16 -0
  163. data/ruby/neo4j/driver/internal/messaging/encode/pull_all_message_encoder.rb +14 -0
  164. data/ruby/neo4j/driver/internal/messaging/encode/pull_message_encoder.rb +15 -0
  165. data/ruby/neo4j/driver/internal/messaging/encode/reset_message_encoder.rb +14 -0
  166. data/ruby/neo4j/driver/internal/messaging/encode/rollback_message_encoder.rb +14 -0
  167. data/ruby/neo4j/driver/internal/messaging/encode/route_message_encoder.rb +18 -0
  168. data/ruby/neo4j/driver/internal/messaging/encode/route_v44_message_encoder.rb +27 -0
  169. data/ruby/neo4j/driver/internal/messaging/encode/run_message_encoder.rb +16 -0
  170. data/ruby/neo4j/driver/internal/messaging/encode/run_with_metadata_message_encoder.rb +17 -0
  171. data/ruby/neo4j/driver/internal/messaging/request/abstract_streaming_message.rb +22 -0
  172. data/ruby/neo4j/driver/internal/messaging/request/begin_message.rb +26 -0
  173. data/ruby/neo4j/driver/internal/messaging/request/commit_message.rb +20 -0
  174. data/ruby/neo4j/driver/internal/messaging/request/discard_all_message.rb +20 -0
  175. data/ruby/neo4j/driver/internal/messaging/request/discard_message.rb +23 -0
  176. data/ruby/neo4j/driver/internal/messaging/request/goodbye_message.rb +20 -0
  177. data/ruby/neo4j/driver/internal/messaging/request/hello_message.rb +31 -0
  178. data/ruby/neo4j/driver/internal/messaging/request/init_message.rb +19 -0
  179. data/ruby/neo4j/driver/internal/messaging/request/message_with_metadata.rb +10 -0
  180. data/ruby/neo4j/driver/internal/messaging/request/multi_database_util.rb +26 -0
  181. data/ruby/neo4j/driver/internal/messaging/request/pull_all_message.rb +23 -0
  182. data/ruby/neo4j/driver/internal/messaging/request/pull_message.rb +22 -0
  183. data/ruby/neo4j/driver/internal/messaging/request/reset_message.rb +32 -0
  184. data/ruby/neo4j/driver/internal/messaging/request/rollback_message.rb +20 -0
  185. data/ruby/neo4j/driver/internal/messaging/request/route_message.rb +33 -0
  186. data/ruby/neo4j/driver/internal/messaging/request/run_message.rb +23 -0
  187. data/ruby/neo4j/driver/internal/messaging/request/run_with_metadata_message.rb +47 -0
  188. data/ruby/neo4j/driver/internal/messaging/request/transaction_metadata_builder.rb +24 -0
  189. data/ruby/neo4j/driver/internal/messaging/response/failure_message.rb +40 -0
  190. data/ruby/neo4j/driver/internal/messaging/response/ignored_message.rb +29 -0
  191. data/ruby/neo4j/driver/internal/messaging/response/record_message.rb +33 -0
  192. data/ruby/neo4j/driver/internal/messaging/response/success_message.rb +34 -0
  193. data/ruby/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +78 -0
  194. data/ruby/neo4j/driver/internal/messaging/v3/message_format_v3.rb +17 -0
  195. data/ruby/neo4j/driver/internal/messaging/v3/message_writer_v3.rb +27 -0
  196. data/ruby/neo4j/driver/internal/messaging/v4/bolt_protocol_v4.rb +29 -0
  197. data/ruby/neo4j/driver/internal/messaging/v4/message_format_v4.rb +17 -0
  198. data/ruby/neo4j/driver/internal/messaging/v4/message_writer_v4.rb +28 -0
  199. data/ruby/neo4j/driver/internal/messaging/v41/bolt_protocol_v41.rb +25 -0
  200. data/ruby/neo4j/driver/internal/messaging/v42/bolt_protocol_v42.rb +13 -0
  201. data/ruby/neo4j/driver/internal/messaging/v43/bolt_protocol_v43.rb +19 -0
  202. data/ruby/neo4j/driver/internal/messaging/v43/message_format_v43.rb +18 -0
  203. data/ruby/neo4j/driver/internal/messaging/v43/message_writer_v43.rb +34 -0
  204. data/ruby/neo4j/driver/internal/messaging/v44/bolt_protocol_v44.rb +17 -0
  205. data/ruby/neo4j/driver/internal/messaging/v44/message_format_v44.rb +18 -0
  206. data/ruby/neo4j/driver/internal/messaging/v44/message_writer_v44.rb +26 -0
  207. data/ruby/neo4j/driver/internal/metrics/connection_pool_metrics_listener.rb +34 -0
  208. data/ruby/neo4j/driver/internal/metrics/internal_abstract_metrics.rb +46 -0
  209. data/ruby/neo4j/driver/internal/metrics/internal_connection_pool_metrics.rb +105 -0
  210. data/ruby/neo4j/driver/internal/metrics/internal_metrics.rb +82 -0
  211. data/ruby/neo4j/driver/internal/metrics/internal_metrics_provider.rb +18 -0
  212. data/ruby/neo4j/driver/internal/metrics/listener_event.rb +17 -0
  213. data/ruby/neo4j/driver/internal/metrics/metrics_provider.rb +24 -0
  214. data/ruby/neo4j/driver/internal/metrics/time_recorder_listener_event.rb +15 -0
  215. data/ruby/neo4j/driver/internal/packstream/byte_array_incompatible_packer.rb +12 -0
  216. data/ruby/neo4j/driver/internal/packstream/pack_input.rb +47 -0
  217. data/ruby/neo4j/driver/internal/packstream/pack_output.rb +39 -0
  218. data/ruby/neo4j/driver/internal/packstream/pack_stream.rb +326 -0
  219. data/ruby/neo4j/driver/internal/packstream/pack_type.rb +17 -0
  220. data/ruby/neo4j/driver/internal/retry/exponential_backoff_retry_logic.rb +151 -0
  221. data/ruby/neo4j/driver/internal/revocation_strategy.rb +19 -0
  222. data/ruby/neo4j/driver/internal/scheme.rb +32 -0
  223. data/ruby/neo4j/driver/internal/security/internal_auth_token.rb +15 -0
  224. data/ruby/neo4j/driver/internal/security/security_plan_impl.rb +43 -0
  225. data/ruby/neo4j/driver/internal/security_setting.rb +66 -0
  226. data/ruby/neo4j/driver/internal/session_factory_impl.rb +32 -0
  227. data/ruby/neo4j/driver/internal/spi/connection.rb +19 -0
  228. data/ruby/neo4j/driver/internal/spi/connection_pool.rb +9 -0
  229. data/ruby/neo4j/driver/internal/spi/response_handler.rb +23 -0
  230. data/ruby/neo4j/driver/internal/summary/internal_database_info.rb +7 -0
  231. data/ruby/neo4j/driver/internal/summary/internal_input_position.rb +11 -0
  232. data/ruby/neo4j/driver/internal/summary/internal_notification.rb +16 -0
  233. data/ruby/neo4j/driver/internal/summary/internal_plan.rb +41 -0
  234. data/ruby/neo4j/driver/internal/summary/internal_profiled_plan.rb +32 -0
  235. data/ruby/neo4j/driver/internal/summary/internal_result_summary.rb +33 -0
  236. data/ruby/neo4j/driver/internal/summary/internal_server_info.rb +6 -0
  237. data/ruby/neo4j/driver/internal/summary/internal_summary_counters.rb +18 -0
  238. data/ruby/neo4j/driver/internal/svm/netty_substitutions.rb +196 -0
  239. data/ruby/neo4j/driver/internal/svm/z_lib_substitutions.rb +21 -0
  240. data/ruby/neo4j/driver/internal/util/certificate_tool.rb +65 -0
  241. data/ruby/neo4j/driver/internal/util/clock.rb +29 -0
  242. data/ruby/neo4j/driver/internal/util/error_util.rb +104 -0
  243. data/ruby/neo4j/driver/internal/util/extract.rb +123 -0
  244. data/ruby/neo4j/driver/internal/util/format.rb +39 -0
  245. data/ruby/neo4j/driver/internal/util/futures.rb +99 -0
  246. data/ruby/neo4j/driver/internal/util/iterables.rb +35 -0
  247. data/ruby/neo4j/driver/internal/util/lock_util.rb +23 -0
  248. data/ruby/neo4j/driver/internal/util/metadata_extractor.rb +109 -0
  249. data/ruby/neo4j/driver/internal/util/mutex.rb +9 -0
  250. data/ruby/neo4j/driver/internal/util/preconditions.rb +16 -0
  251. data/ruby/neo4j/driver/internal/util/server_version.rb +60 -0
  252. data/ruby/neo4j/driver/logging1.rb +51 -0
  253. data/ruby/neo4j/driver/net/server_address1.rb +9 -0
  254. data/ruby/neo4j/driver/query.rb +48 -0
  255. data/ruby/neo4j/driver/records.rb +13 -0
  256. data/ruby/neo4j/driver/session_config.rb +15 -0
  257. data/ruby/neo4j/driver/transaction_config.rb +46 -0
  258. data/ruby/neo4j/driver/values.rb +26 -0
  259. data/{lib → ruby}/neo4j/driver/version.rb +1 -1
  260. data/ruby/neo4j/driver.rb +30 -0
  261. metadata +267 -92
  262. data/ffi/bolt/address.rb +0 -11
  263. data/ffi/bolt/address_resolver.rb +0 -12
  264. data/ffi/bolt/address_set.rb +0 -9
  265. data/ffi/bolt/auth.rb +0 -10
  266. data/ffi/bolt/auto_releasable.rb +0 -22
  267. data/ffi/bolt/boolean.rb +0 -9
  268. data/ffi/bolt/bytes.rb +0 -10
  269. data/ffi/bolt/config.rb +0 -45
  270. data/ffi/bolt/connection.rb +0 -44
  271. data/ffi/bolt/connector.rb +0 -17
  272. data/ffi/bolt/dictionary.rb +0 -15
  273. data/ffi/bolt/error.rb +0 -74
  274. data/ffi/bolt/float.rb +0 -9
  275. data/ffi/bolt/integer.rb +0 -9
  276. data/ffi/bolt/library.rb +0 -12
  277. data/ffi/bolt/lifecycle.rb +0 -9
  278. data/ffi/bolt/list.rb +0 -10
  279. data/ffi/bolt/log.rb +0 -16
  280. data/ffi/bolt/socket_options.rb +0 -14
  281. data/ffi/bolt/status.rb +0 -25
  282. data/ffi/bolt/string.rb +0 -9
  283. data/ffi/bolt/structure.rb +0 -10
  284. data/ffi/bolt/value.rb +0 -35
  285. data/ffi/neo4j/driver/auth_tokens.rb +0 -18
  286. data/ffi/neo4j/driver/config.rb +0 -40
  287. data/ffi/neo4j/driver/graph_database.rb +0 -52
  288. data/ffi/neo4j/driver/internal/async/access_mode_connection.rb +0 -19
  289. data/ffi/neo4j/driver/internal/async/direct_connection.rb +0 -106
  290. data/ffi/neo4j/driver/internal/bolt_server_address.rb +0 -18
  291. data/ffi/neo4j/driver/internal/bookmarks_holder.rb +0 -30
  292. data/ffi/neo4j/driver/internal/direct_connection_provider.rb +0 -28
  293. data/ffi/neo4j/driver/internal/driver_factory.rb +0 -126
  294. data/ffi/neo4j/driver/internal/error_handling.rb +0 -112
  295. data/ffi/neo4j/driver/internal/explicit_transaction.rb +0 -146
  296. data/ffi/neo4j/driver/internal/handlers/pull_all_response_handler.rb +0 -104
  297. data/ffi/neo4j/driver/internal/handlers/response_handler.rb +0 -49
  298. data/ffi/neo4j/driver/internal/handlers/run_response_handler.rb +0 -32
  299. data/ffi/neo4j/driver/internal/handlers/session_pull_all_response_handler.rb +0 -32
  300. data/ffi/neo4j/driver/internal/handlers/transaction_pull_all_response_handler.rb +0 -23
  301. data/ffi/neo4j/driver/internal/internal_driver.rb +0 -45
  302. data/ffi/neo4j/driver/internal/internal_logger.rb +0 -32
  303. data/ffi/neo4j/driver/internal/internal_resolver.rb +0 -31
  304. data/ffi/neo4j/driver/internal/internal_statement_result.rb +0 -52
  305. data/ffi/neo4j/driver/internal/messaging/bolt_protocol.rb +0 -24
  306. data/ffi/neo4j/driver/internal/messaging/v1/bolt_protocol_v1.rb +0 -59
  307. data/ffi/neo4j/driver/internal/messaging/v2/bolt_protocol_v2.rb +0 -16
  308. data/ffi/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +0 -63
  309. data/ffi/neo4j/driver/internal/network_session.rb +0 -129
  310. data/ffi/neo4j/driver/internal/retry/exponential_backoff_retry_logic.rb +0 -80
  311. data/ffi/neo4j/driver/internal/session_factory_impl.rb +0 -28
  312. data/ffi/neo4j/driver/internal/summary/internal_result_summary.rb +0 -67
  313. data/ffi/neo4j/driver/internal/summary/internal_server_info.rb +0 -19
  314. data/ffi/neo4j/driver/internal/summary/internal_summary_counters.rb +0 -23
  315. data/ffi/neo4j/driver/internal/util/metadata_extractor.rb +0 -15
  316. data/ffi/neo4j/driver/internal/value/base_time_value.rb +0 -22
  317. data/ffi/neo4j/driver/internal/value/date_value.rb +0 -25
  318. data/ffi/neo4j/driver/internal/value/duration_value.rb +0 -27
  319. data/ffi/neo4j/driver/internal/value/local_date_time_value.rb +0 -24
  320. data/ffi/neo4j/driver/internal/value/local_time_value.rb +0 -19
  321. data/ffi/neo4j/driver/internal/value/node_value.rb +0 -18
  322. data/ffi/neo4j/driver/internal/value/offset_time_value.rb +0 -25
  323. data/ffi/neo4j/driver/internal/value/path_value.rb +0 -41
  324. data/ffi/neo4j/driver/internal/value/point2_d_value.rb +0 -24
  325. data/ffi/neo4j/driver/internal/value/point3_d_value.rb +0 -24
  326. data/ffi/neo4j/driver/internal/value/relationship_value.rb +0 -18
  327. data/ffi/neo4j/driver/internal/value/structure_value.rb +0 -42
  328. data/ffi/neo4j/driver/internal/value/time_with_zone_id_value.rb +0 -25
  329. data/ffi/neo4j/driver/internal/value/time_with_zone_offset_value.rb +0 -28
  330. data/ffi/neo4j/driver/internal/value/unbound_relationship_value.rb +0 -18
  331. data/ffi/neo4j/driver/internal/value/value_adapter.rb +0 -101
  332. data/ffi/neo4j/driver/net/server_address.rb +0 -13
  333. data/ffi/neo4j/driver/statement.rb +0 -15
  334. data/ffi/neo4j/driver/types/entity.rb +0 -21
  335. data/ffi/neo4j/driver/types/node.rb +0 -16
  336. data/ffi/neo4j/driver/types/path.rb +0 -35
  337. data/ffi/neo4j/driver/types/relationship.rb +0 -19
  338. data/ffi/neo4j/driver.rb +0 -61
  339. data/lib/neo4j/driver/internal/ruby_signature.rb +0 -18
@@ -0,0 +1,78 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalDriver
4
+ extend AutoClosable
5
+ extend Synchronizable
6
+ attr_reader :session_factory, :metrics_provider
7
+ # delegate :verify_connectivity, to: :session_factory
8
+ delegate :metrics, :metrics_enabled?, to: :metrics_provider
9
+ auto_closable :session
10
+ sync :close, :supports_multi_db?, :verify_connectivity
11
+
12
+ def initialize(security_plan, session_factory, metrics_provider, logger)
13
+ @closed = Concurrent::AtomicBoolean.new(false)
14
+ @security_plan = security_plan
15
+ @session_factory = session_factory
16
+ @metrics_provider = metrics_provider
17
+ @log = logger
18
+ end
19
+
20
+ def session(**session_config)
21
+ InternalSession.new(new_session(**session_config))
22
+ end
23
+
24
+ def rx_session(**session_config)
25
+ InternalRxSession.new(new_session(**session_config))
26
+ end
27
+
28
+ def async_session(**session_config)
29
+ InternalAsyncSession.new(new_session(**session_config))
30
+ end
31
+
32
+ def encrypted?
33
+ assert_open!
34
+ @security_plan.requires_encryption?
35
+ end
36
+
37
+ def close
38
+ close_async
39
+ end
40
+
41
+ def close_async
42
+ return nil unless @closed.make_true
43
+ @log.info { "Closing driver instance #{object_id}" }
44
+ session_factory.close
45
+ end
46
+
47
+ def verify_connectivity_async
48
+ session_factory.verify_connectivity
49
+ end
50
+
51
+ def supports_multi_db?
52
+ supports_multi_db_async?
53
+ end
54
+
55
+ def supports_multi_db_async?
56
+ session_factory.supports_multi_db?
57
+ end
58
+
59
+ def verify_connectivity
60
+ verify_connectivity_async
61
+ end
62
+
63
+ def new_session(**config)
64
+ assert_open!
65
+ session_factory.new_instance(**config.compact)
66
+ ensure
67
+ # session does not immediately acquire connection, it is fine to just throw
68
+ assert_open!
69
+ end
70
+
71
+ private
72
+
73
+ def assert_open!
74
+ raise Exceptions::IllegalStateException, 'This driver instance has already been closed' if @closed.true?
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,22 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalEntity
4
+ attr_reader :id, :properties
5
+ delegate :hash, to: :id
6
+ delegate :[], :size, :key?, :keys, :values, :to_h, to: :properties
7
+
8
+ def initialize(id, properties)
9
+ @id = id
10
+ @properties = properties
11
+ end
12
+
13
+ def eql?(other)
14
+ id.eql?(other.id)
15
+ end
16
+
17
+ def ==(other)
18
+ id == other.id
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ # {@link Node} implementation that directly contains labels and properties.
4
+ class InternalNode < InternalEntity
5
+ attr_reader :labels
6
+
7
+ def initialize(id, *labels, **properties)
8
+ super(id, properties)
9
+ @labels = labels
10
+ end
11
+
12
+ def label?(label)
13
+ labels.include?(label)
14
+ end
15
+
16
+ def to_s
17
+ "node<#{id}>"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalPair < Struct.new(:key, :value)
4
+ def self.of(key, value)
5
+ new(key, value)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalPath < Array
4
+ attr_reader :nodes, :relationships
5
+
6
+ class Segment < Struct.new(:start_node, :relationship, :end_node)
7
+ def to_s
8
+ sprintf(relationship.start_node_id == start_node.id ? '(%s)-[%s:%s]->(%s)' : '(%s)<-[%s:%s]-(%s)',
9
+ start_node.id, relationship.id, relationship.type, end_node.id)
10
+ end
11
+ end
12
+
13
+ delegate :length, to: :relationships
14
+ delegate :include?, to: :entities
15
+
16
+ def initialize(nodes, relationships)
17
+ super()
18
+ @nodes = nodes
19
+ @relationships = relationships
20
+ end
21
+
22
+ def to_s
23
+ 'path' + super
24
+ end
25
+
26
+ def start_node
27
+ @nodes.first
28
+ end
29
+
30
+ def end_node
31
+ @nodes.last
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,9 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalPoint2D < Struct.new(:srid, :x, :y)
4
+ def z
5
+ Float::NAN
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalPoint3D < Struct.new(:srid, :x, :y, :z)
4
+ end
5
+ end
6
+ end
@@ -5,7 +5,8 @@ module Neo4j
5
5
  module Internal
6
6
  class InternalRecord
7
7
  attr_reader :keys, :values
8
- delegate :first, to: :values
8
+ delegate :first, :size,to: :values
9
+ delegate :key?, to: :keys
9
10
 
10
11
  def initialize(keys, values)
11
12
  @keys = keys
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neo4j::Driver
4
+ module Internal
5
+ class InternalRelationship < InternalEntity
6
+ attr_accessor :start_node_id, :end_node_id
7
+ attr_reader :type
8
+
9
+ def initialize(id, start_node_id, end_node_id, type, **properties)
10
+ super(id, properties)
11
+ @start_node_id = start_node_id
12
+ @end_node_id = end_node_id
13
+ @type = type.to_sym
14
+ end
15
+
16
+ def start_and_end_node_ids=(start_node_id, end_node_id)
17
+ @start_node_id = start_node_id
18
+ @end_node_id = end_node_id
19
+ end
20
+
21
+ def to_s
22
+ "relationship<#{id}>"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,60 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalResult
4
+ extend Synchronizable
5
+ include Enumerable
6
+ sync :keys, :has_next?, :next, :single, :peek, :consume
7
+
8
+ def initialize(connection, cursor)
9
+ @connection = connection
10
+ @cursor = cursor
11
+ end
12
+
13
+ def keys
14
+ @keys ||=
15
+ begin
16
+ @cursor.peek_async
17
+ @cursor.keys
18
+ end
19
+ end
20
+
21
+ def has_next?
22
+ @cursor.peek_async
23
+ end
24
+
25
+ def next
26
+ @cursor.next_async || raise(Exceptions::NoSuchRecordException.no_more)
27
+ end
28
+
29
+ def single
30
+ @cursor.single_async
31
+ end
32
+
33
+ def peek
34
+ @cursor.peek_async or raise Exceptions::NoSuchRecordException.no_peek_past
35
+ end
36
+
37
+ def each
38
+ yield self.next while has_next?
39
+ end
40
+
41
+ def consume
42
+ @cursor.consume_async
43
+ end
44
+
45
+ def remove
46
+ raise ClientException, 'Removing records from a result is not supported.'
47
+ end
48
+
49
+ private
50
+
51
+ def blocking_get(stage)
52
+ Util::Futures.blocking_get(stage, &method(:terminate_connection_on_thread_interrupt))
53
+ end
54
+
55
+ def terminate_connection_on_thread_interrupt
56
+ @connection.terminate_and_release('Thread interrupted while waiting for result to arrive')
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,81 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalSession
4
+ extend AutoClosable
5
+ extend Synchronizable
6
+ # include Ext::RunOverride
7
+ delegate :open?, :last_bookmark, to: :@session
8
+ auto_closable :begin_transaction
9
+ sync :close, :begin_transaction, :run, :transaction
10
+
11
+ def initialize(session)
12
+ @session = session
13
+ end
14
+
15
+ def run(query, parameters = {}, config = {})
16
+ parameters ||= {}
17
+ Validator.require_hash_parameters!(parameters)
18
+ cursor = @session.run_async(Query.new(query, **parameters), **TransactionConfig.new(**config.compact)) do
19
+ terminate_connection_on_thread_interrupt('Thread interrupted while running query in session')
20
+ end
21
+
22
+ # query executed, it is safe to obtain a connection in a blocking way
23
+ connection = @session.connection_async
24
+ InternalResult.new(connection, cursor)
25
+ end
26
+
27
+ def close
28
+ @session.close_async do
29
+ terminate_connection_on_thread_interrupt("Thread interrupted while closing the session")
30
+ end
31
+ end
32
+
33
+ def begin_transaction(**config)
34
+ tx = @session.begin_transaction_async(**config) do
35
+ terminate_connection_on_thread_interrupt("Thread interrupted while starting a transaction")
36
+ end
37
+ InternalTransaction.new(tx)
38
+ end
39
+
40
+ def read_transaction(**config, &block)
41
+ transaction(AccessMode::READ, **config, &block)
42
+ end
43
+
44
+ def write_transaction(**config, &block)
45
+ transaction(AccessMode::WRITE, **config, &block)
46
+ end
47
+
48
+ private
49
+
50
+ def transaction(mode, **config)
51
+ # use different code path compared to async so that work is executed in the caller thread
52
+ # caller thread will also be the one who sleeps between retries;
53
+ # it is unsafe to execute retries in the event loop threads because this can cause a deadlock
54
+ # event loop thread will bock and wait for itself to read some data
55
+ @session.retry_logic.retry do
56
+ tx = private_begin_transaction(mode, **config)
57
+ result = yield tx
58
+ tx.commit if tx.open? # if a user has not explicitly committed or rolled back the transaction
59
+ result
60
+ ensure
61
+ tx&.close
62
+ end
63
+ end
64
+
65
+ def private_begin_transaction(mode, **config)
66
+ tx = @session.begin_transaction_async(mode, **config) do
67
+ terminate_connection_on_thread_interrupt("Thread interrupted while starting a transaction")
68
+ end
69
+ InternalTransaction.new(tx)
70
+ end
71
+
72
+ def terminate_connection_on_thread_interrupt(reason)
73
+ connection = @session.connection_async
74
+ rescue
75
+ nil # ignore errors because handing interruptions is best effort
76
+ ensure
77
+ connection&.terminate_and_release(reason)
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,48 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class InternalTransaction
4
+ extend Synchronizable
5
+ sync :commit, :rollback, :close, :run
6
+ delegate :open?, to: :@tx
7
+
8
+ def initialize(tx)
9
+ @tx = tx
10
+ end
11
+
12
+ def commit
13
+ @tx.commit_async
14
+ # org.neo4j.driver.internal.util.Futures.blockingGet(@tx.commit_async) do
15
+ # terminate_connection_on_thread_interrupt('Thread interrupted while committing the transaction')
16
+ # end
17
+ end
18
+
19
+ def rollback
20
+ @tx.rollback_async
21
+ # org.neo4j.driver.internal.util.Futures.blockingGet(@tx.rollback_async) do
22
+ # terminate_connection_on_thread_interrupt('Thread interrupted while rolling back the transaction')
23
+ # end
24
+ end
25
+
26
+ def close
27
+ @tx.close_async
28
+ # org.neo4j.driver.internal.util.Futures.blockingGet(@tx.close_async) do
29
+ # terminate_connection_on_thread_interrupt('Thread interrupted while closing the transaction')
30
+ # end
31
+ end
32
+
33
+ def run(query, **parameters)
34
+ cursor = @tx.run_async(Query.new(query, **parameters))
35
+ # cursor = org.neo4j.driver.internal.util.Futures.blockingGet(@tx.run_async(to_statement(query, parameters))) do
36
+ # terminate_connection_on_thread_interrupt('Thread interrupted while running query in transaction')
37
+ # end
38
+ InternalResult.new(@tx.connection, cursor)
39
+ end
40
+
41
+ private
42
+
43
+ def terminate_connection_on_thread_interrupt(reason)
44
+ @tx.connection.terminate_and_release(reason)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Logging
4
+ class ChannelActivityLogger < ReformattedLogger
5
+ def initialize(channel, logger, owner)
6
+ super(logger)
7
+ @channel = channel
8
+ @local_channel_id = channel&.object_id&.to_s
9
+ @owner = owner
10
+ end
11
+
12
+ private
13
+
14
+ def format_message(severity, datetime, progname, msg)
15
+ super(severity, datetime, @owner || progname,
16
+ @channel && "[0x#{@local_channel_id}] [#{server_address}] [#{db_connection_id}] #{msg}" || msg)
17
+ end
18
+
19
+ def db_connection_id
20
+ @db_connection_id ||= Async::Connection::ChannelAttributes.connection_id(@channel)
21
+ end
22
+
23
+ def server_address
24
+ @server_address ||= Async::Connection::ChannelAttributes.server_address(@channel)&.to_s
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Logging
4
+ class ChannelErrorLogger < ChannelActivityLogger
5
+ DEBUG_MESSAGE_FORMAT = "%s (%s)"
6
+
7
+ def initialize(channel, logger)
8
+ super(channel, logger, self.class)
9
+ end
10
+
11
+ def debug(message, error)
12
+ super(DEBUG_MESSAGE_FORMAT % [message, error.class])
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Logging
4
+ class PrefixedLogger < ReformattedLogger
5
+ def initialize(message_prefix = nil, delegate)
6
+ super(delegate)
7
+ @message_prefix = message_prefix
8
+ end
9
+
10
+ private
11
+
12
+ def format_message(severity, datetime, progname, msg)
13
+ return super unless @message_prefix
14
+ super(severity, datetime, progname, "#{@message_prefix} #{msg}")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Logging
4
+ class ReformattedLogger
5
+ delegate_missing_to :@delegate
6
+
7
+ def initialize(delegate)
8
+ @delegate = Validator.require_non_nil!(delegate)
9
+ end
10
+
11
+ def trace(*arg)
12
+ debug(*arg)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Messaging
4
+ class AbstractMessageWriter
5
+ def initialize(packer)
6
+ @packer = Internal::Validator.require_non_nil!(packer)
7
+ @encoders_by_message_signature = Internal::Validator.require_non_nil!(build_encoders)
8
+ end
9
+
10
+ def write(msg)
11
+ signature = msg.class::SIGNATURE
12
+ encoder = @encoders_by_message_signature[signature]
13
+
14
+ if encoder.nil?
15
+ raise IOError, "No encoder found for message #{msg} with signature #{signature}"
16
+ end
17
+
18
+ encoder.encode(msg, @packer)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,30 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Messaging
4
+ module BoltProtocol
5
+ def self.for_channel(channel)
6
+ for_version(channel.attributes[:protocol_version])
7
+ end
8
+
9
+ def self.for_version(version)
10
+ case version
11
+ when V3::BoltProtocolV3::VERSION
12
+ V3::BoltProtocolV3::INSTANCE
13
+ when V4::BoltProtocolV4::VERSION
14
+ V4::BoltProtocolV4::INSTANCE
15
+ when V41::BoltProtocolV41::VERSION
16
+ V41::BoltProtocolV41::INSTANCE
17
+ when V42::BoltProtocolV42::VERSION
18
+ V42::BoltProtocolV42::INSTANCE
19
+ when V43::BoltProtocolV43::VERSION
20
+ V43::BoltProtocolV43::INSTANCE
21
+ when V44::BoltProtocolV44::VERSION
22
+ V44::BoltProtocolV44::INSTANCE
23
+ else
24
+ raise Exceptions::ClientException, "Unknown protocol version: #{version}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,46 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Messaging
4
+ class BoltProtocolVersion < Struct.new(:major_version, :minor_version)
5
+ def self.from_raw_bytes(raw_version)
6
+ major = raw_version & 0x000000FF
7
+ minor = (raw_version >> 8) & 0x000000FF
8
+ new(major,minor)
9
+ end
10
+
11
+ def to_int
12
+ shifted_minor = minor_version << 8
13
+ shifted_minor | major_version
14
+ end
15
+
16
+ def to_int_range(min_version)
17
+ if major_version != min_version.major_version
18
+ raise ArgumentError, 'Versions should be from the same major version'
19
+ elsif minor_version < min_version.minor_version
20
+ raise ArgumentError, 'Max version should be newer than min version'
21
+ end
22
+
23
+ range = minor_version - min_version.minor_version
24
+ shifted_range = range << 16
25
+ shifted_range | to_int
26
+ end
27
+
28
+ # @return the version in format X.Y where X is the major version and Y is the minor version
29
+ def to_s
30
+ values.join('.')
31
+ end
32
+
33
+ def <=>(other)
34
+ result = major_version <=> other.major_version
35
+ result == 0 ? minor_version <=> other.minor_version : result
36
+ end
37
+
38
+ def self.http?(protocol_version)
39
+ # server would respond with `HTTP..` We read 4 bytes to figure out the version. The first two are not used
40
+ # and therefore parse the `P` (80) for major and `T` (84) for minor.
41
+ protocol_version.major_version == 80 && protocol_version.minor_version == 84
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,51 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Messaging
4
+ module Common
5
+ class CommonMessageReader
6
+ def initialize(input)
7
+ @unpacker = input
8
+ end
9
+
10
+ def read(handler)
11
+ @unpacker.unpack_struct_header
12
+ type = @unpacker.unpack_struct_signature
13
+
14
+ case type
15
+ when Response::SuccessMessage::SIGNATURE
16
+ unpack_success_message(handler)
17
+ when Response::FailureMessage::SIGNATURE
18
+ unpack_failure_message(handler)
19
+ when Response::IgnoredMessage::SIGNATURE
20
+ unpack_ignored_message(handler)
21
+ when Response::RecordMessage::SIGNATURE
22
+ unpack_record_message(handler)
23
+ else
24
+ raise IOError, "Unknown message type: #{type}"
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def unpack_success_message(output)
31
+ map = @unpacker.unpack
32
+ output.handle_success_message(map)
33
+ end
34
+
35
+ def unpack_failure_message(output)
36
+ output.handle_failure_message(**@unpacker.unpack)
37
+ end
38
+
39
+ def unpack_ignored_message(output)
40
+ output.handle_ignored_message
41
+ end
42
+
43
+ def unpack_record_message(output)
44
+ fields = @unpacker.unpack
45
+ output.handle_record_message(fields)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,31 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Messaging
4
+ module Common
5
+ module CommonValue
6
+ include Packstream::PackStream::Common
7
+ DATE = 'D'
8
+ DATE_STRUCT_SIZE = 1
9
+ TIME = 'T'
10
+ TIME_STRUCT_SIZE = 2
11
+ LOCAL_TIME = 't'
12
+ LOCAL_TIME_STRUCT_SIZE = 1
13
+ LOCAL_DATE_TIME = 'd'
14
+ LOCAL_DATE_TIME_STRUCT_SIZE = 2
15
+ DATE_TIME_WITH_ZONE_OFFSET = 'F'
16
+ DATE_TIME_WITH_ZONE_ID = 'f'
17
+ DATE_TIME_STRUCT_SIZE = 3
18
+ DURATION = 'E'
19
+ DURATION_TIME_STRUCT_SIZE = 4
20
+ POINT_2D_STRUCT_TYPE = 'X'
21
+ POINT_2D_STRUCT_SIZE = 3
22
+ POINT_3D_STRUCT_TYPE = 'Y'
23
+ POINT_3D_STRUCT_SIZE = 4
24
+
25
+ EPOCH = Date.parse('1970-01-01')
26
+ NANO_FACTOR = 1_000_000_000
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end