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.
- checksums.yaml +4 -4
- data/README.md +37 -43
- data/lib/loader.rb +5 -3
- data/lib/neo4j/driver/auto_closable.rb +2 -2
- data/lib/neo4j/driver/exceptions/authentication_exception.rb +6 -1
- data/lib/neo4j/driver/exceptions/authorization_expired_exception.rb +14 -0
- data/lib/neo4j/driver/{types/bytes.rb → exceptions/certificate_exception.rb} +2 -2
- data/lib/neo4j/driver/exceptions/client_exception.rb +3 -0
- data/lib/neo4j/driver/exceptions/connection_read_timeout_exception.rb +14 -0
- data/lib/neo4j/driver/exceptions/database_exception.rb +3 -0
- data/lib/neo4j/driver/exceptions/discovery_exception.rb +16 -0
- data/lib/neo4j/driver/exceptions/fatal_discovery_exception.rb +13 -0
- data/lib/neo4j/driver/exceptions/protocol_exception.rb +7 -0
- data/lib/neo4j/driver/exceptions/result_consumed_exception.rb +13 -0
- data/lib/neo4j/driver/exceptions/security_exception.rb +5 -1
- data/lib/neo4j/driver/exceptions/service_unavailable_exception.rb +2 -0
- data/lib/neo4j/driver/exceptions/session_expired_exception.rb +4 -0
- data/lib/neo4j/driver/exceptions/token_expired_exception.rb +15 -0
- data/lib/neo4j/driver/exceptions/transaction_nesting_exception.rb +11 -0
- data/lib/neo4j/driver/exceptions/transient_exception.rb +3 -0
- data/lib/neo4j/driver/exceptions/untrusted_server_exception.rb +1 -0
- data/lib/neo4j/driver/exceptions/value/lossy_coercion.rb +15 -0
- data/lib/neo4j/driver/exceptions/value/not_multi_valued.rb +13 -0
- data/lib/neo4j/driver/exceptions/value/uncoercible.rb +15 -0
- data/lib/neo4j/driver/exceptions/value/unsizable.rb +12 -0
- data/lib/neo4j/driver/exceptions/value/value_exception.rb +12 -0
- data/lib/neo4j/driver/internal/bolt_server_address.rb +97 -0
- data/lib/neo4j/driver/internal/duration_normalizer.rb +1 -1
- data/lib/neo4j/driver/internal/validator.rb +5 -4
- data/{ffi/neo4j/driver/summary/statement_type.rb → lib/neo4j/driver/summary/query_type.rb} +1 -3
- data/lib/neo4j/driver/synchronizable.rb +23 -0
- data/lib/neo4j_ruby_driver.rb +5 -11
- data/{ffi → ruby}/neo4j/driver/access_mode.rb +2 -2
- data/ruby/neo4j/driver/auth_tokens.rb +34 -0
- data/ruby/neo4j/driver/bookmark.rb +21 -0
- data/ruby/neo4j/driver/config.rb +89 -0
- data/ruby/neo4j/driver/graph_database.rb +80 -0
- data/ruby/neo4j/driver/internal/async/connection/bolt_protocol_util.rb +51 -0
- data/ruby/neo4j/driver/internal/async/connection/bootstrap_factory.rb +22 -0
- data/ruby/neo4j/driver/internal/async/connection/channel_attributes.rb +31 -0
- data/ruby/neo4j/driver/internal/async/connection/channel_connected_listener.rb +32 -0
- data/ruby/neo4j/driver/internal/async/connection/channel_connector_impl.rb +83 -0
- data/ruby/neo4j/driver/internal/async/connection/channel_pipeline_builder_impl.rb +22 -0
- data/ruby/neo4j/driver/internal/async/connection/direct_connection.rb +30 -0
- data/ruby/neo4j/driver/internal/async/connection/event_loop_group_factory.rb +83 -0
- data/ruby/neo4j/driver/internal/async/connection/handshake_completed_listener.rb +27 -0
- data/ruby/neo4j/driver/internal/async/connection/handshake_handler.rb +113 -0
- data/ruby/neo4j/driver/internal/async/connection/netty_channel_initializer.rb +57 -0
- data/ruby/neo4j/driver/internal/async/connection/netty_domain_name_resolver.rb +26 -0
- data/ruby/neo4j/driver/internal/async/connection/netty_domain_name_resolver_group.rb +19 -0
- data/ruby/neo4j/driver/internal/async/connection/routing_connection.rb +36 -0
- data/ruby/neo4j/driver/internal/async/connection/stream.rb +12 -0
- data/ruby/neo4j/driver/internal/async/connection/stream_reader.rb +16 -0
- data/ruby/neo4j/driver/internal/async/connection_context.rb +10 -0
- data/ruby/neo4j/driver/internal/async/immutable_connection_context.rb +24 -0
- data/ruby/neo4j/driver/internal/async/inbound/byte_buf_input.rb +30 -0
- data/ruby/neo4j/driver/internal/async/inbound/channel_error_handler.rb +77 -0
- data/ruby/neo4j/driver/internal/async/inbound/chunk_decoder.rb +41 -0
- data/ruby/neo4j/driver/internal/async/inbound/connect_timeout_handler.rb +32 -0
- data/ruby/neo4j/driver/internal/async/inbound/connection_read_timeout_handler.rb +17 -0
- data/ruby/neo4j/driver/internal/async/inbound/inbound_message_dispatcher.rb +172 -0
- data/ruby/neo4j/driver/internal/async/inbound/inbound_message_handler.rb +42 -0
- data/ruby/neo4j/driver/internal/async/inbound/message_decoder.rb +51 -0
- data/ruby/neo4j/driver/internal/async/internal_async_session.rb +98 -0
- data/ruby/neo4j/driver/internal/async/internal_async_transaction.rb +13 -0
- data/ruby/neo4j/driver/internal/async/leak_logging_network_session.rb +34 -0
- data/ruby/neo4j/driver/internal/async/network_connection.rb +196 -0
- data/ruby/neo4j/driver/internal/async/network_session.rb +152 -0
- data/ruby/neo4j/driver/internal/async/outbound/chunk_aware_byte_buf_output.rb +110 -0
- data/ruby/neo4j/driver/internal/async/outbound/outbound_message_handler.rb +39 -0
- data/ruby/neo4j/driver/internal/async/pool/channel.rb +63 -0
- data/ruby/neo4j/driver/internal/async/pool/connection_pool_impl.rb +149 -0
- data/ruby/neo4j/driver/internal/async/pool/controller.rb +25 -0
- data/ruby/neo4j/driver/internal/async/pool/netty_channel_health_checker.rb +87 -0
- data/ruby/neo4j/driver/internal/async/pool/netty_channel_pool.rb +52 -0
- data/ruby/neo4j/driver/internal/async/pool/netty_channel_tracker.rb +137 -0
- data/ruby/neo4j/driver/internal/async/pool/network_connection_factory.rb +21 -0
- data/ruby/neo4j/driver/internal/async/pool/pool_settings.rb +34 -0
- data/ruby/neo4j/driver/internal/async/result_cursors_holder.rb +17 -0
- data/ruby/neo4j/driver/internal/async/unmanaged_transaction.rb +214 -0
- data/ruby/neo4j/driver/internal/bookmark_holder.rb +9 -0
- data/ruby/neo4j/driver/internal/cluster/cluster_composition.rb +58 -0
- data/ruby/neo4j/driver/internal/cluster/cluster_composition_lookup_result.rb +14 -0
- data/ruby/neo4j/driver/internal/cluster/cluster_routing_table.rb +139 -0
- data/ruby/neo4j/driver/internal/cluster/identity_resolver.rb +13 -0
- data/ruby/neo4j/driver/internal/cluster/loadbalancing/least_connected_load_balancing_strategy.rb +68 -0
- data/ruby/neo4j/driver/internal/cluster/loadbalancing/load_balancer.rb +159 -0
- data/ruby/neo4j/driver/internal/cluster/loadbalancing/round_robin_array_index.rb +13 -0
- data/ruby/neo4j/driver/internal/cluster/multi_databases_routing_procedure_runner.rb +34 -0
- data/ruby/neo4j/driver/internal/cluster/rediscovery_impl.rb +238 -0
- data/ruby/neo4j/driver/internal/cluster/route_message_routing_procedure_runner.rb +43 -0
- data/ruby/neo4j/driver/internal/cluster/routing_context.rb +77 -0
- data/ruby/neo4j/driver/internal/cluster/routing_procedure_cluster_composition_provider.rb +64 -0
- data/ruby/neo4j/driver/internal/cluster/routing_procedure_response.rb +19 -0
- data/ruby/neo4j/driver/internal/cluster/routing_settings.rb +24 -0
- data/ruby/neo4j/driver/internal/cluster/routing_table_handler_impl.rb +116 -0
- data/ruby/neo4j/driver/internal/cluster/routing_table_registry_impl.rb +140 -0
- data/ruby/neo4j/driver/internal/cluster/single_database_routing_procedure_runner.rb +76 -0
- data/ruby/neo4j/driver/internal/connection_settings.rb +16 -0
- data/ruby/neo4j/driver/internal/cursor/async_result_cursor_impl.rb +68 -0
- data/ruby/neo4j/driver/internal/cursor/async_result_cursor_only_factory.rb +28 -0
- data/ruby/neo4j/driver/internal/cursor/disposable_async_result_cursor.rb +59 -0
- data/ruby/neo4j/driver/internal/cursor/result_cursor_factory_impl.rb +29 -0
- data/ruby/neo4j/driver/internal/cursor/rx_result_cursor_impl.rb +110 -0
- data/ruby/neo4j/driver/internal/database_name.rb +12 -0
- data/ruby/neo4j/driver/internal/database_name_util.rb +37 -0
- data/ruby/neo4j/driver/internal/default_bookmark_holder.rb +15 -0
- data/ruby/neo4j/driver/internal/default_domain_name_resolver.rb +11 -0
- data/ruby/neo4j/driver/internal/direct_connection_provider.rb +40 -0
- data/ruby/neo4j/driver/internal/driver_factory.rb +126 -0
- data/ruby/neo4j/driver/internal/handlers/begin_tx_response_handler.rb +20 -0
- data/ruby/neo4j/driver/internal/handlers/channel_releasing_reset_response_handler.rb +29 -0
- data/ruby/neo4j/driver/internal/handlers/commit_tx_response_handler.rb +25 -0
- data/ruby/neo4j/driver/internal/handlers/hello_response_handler.rb +65 -0
- data/ruby/neo4j/driver/internal/handlers/init_response_handler.rb +34 -0
- data/ruby/neo4j/driver/internal/handlers/legacy_pull_all_response_handler.rb +228 -0
- data/ruby/neo4j/driver/internal/handlers/no_op_response_handler.rb +16 -0
- data/ruby/neo4j/driver/internal/handlers/ping_response_handler.rb +29 -0
- data/ruby/neo4j/driver/internal/handlers/pull_handlers.rb +32 -0
- data/ruby/neo4j/driver/internal/handlers/pulln/auto_pull_response_handler.rb +178 -0
- data/ruby/neo4j/driver/internal/handlers/pulln/basic_pull_response_handler.rb +288 -0
- data/ruby/neo4j/driver/internal/handlers/pulln/fetch_size_util.rb +20 -0
- data/ruby/neo4j/driver/internal/handlers/reset_response_handler.rb +34 -0
- data/ruby/neo4j/driver/internal/handlers/rollback_tx_response_handler.rb +19 -0
- data/ruby/neo4j/driver/internal/handlers/route_message_response_handler.rb +21 -0
- data/ruby/neo4j/driver/internal/handlers/routing_response_handler.rb +70 -0
- data/ruby/neo4j/driver/internal/handlers/run_response_handler.rb +38 -0
- data/ruby/neo4j/driver/internal/handlers/session_pull_response_completion_listener.rb +34 -0
- data/ruby/neo4j/driver/internal/handlers/transaction_pull_response_completion_listener.rb +20 -0
- data/ruby/neo4j/driver/internal/impersonation_util.rb +22 -0
- data/ruby/neo4j/driver/internal/internal_bookmark.rb +38 -0
- data/ruby/neo4j/driver/internal/internal_database_name.rb +11 -0
- data/ruby/neo4j/driver/internal/internal_driver.rb +78 -0
- data/ruby/neo4j/driver/internal/internal_entity.rb +22 -0
- data/ruby/neo4j/driver/internal/internal_node.rb +21 -0
- data/ruby/neo4j/driver/internal/internal_pair.rb +9 -0
- data/ruby/neo4j/driver/internal/internal_path.rb +35 -0
- data/ruby/neo4j/driver/internal/internal_point2_d.rb +9 -0
- data/ruby/neo4j/driver/internal/internal_point3_d.rb +6 -0
- data/{ffi → ruby}/neo4j/driver/internal/internal_record.rb +2 -1
- data/ruby/neo4j/driver/internal/internal_relationship.rb +26 -0
- data/ruby/neo4j/driver/internal/internal_result.rb +60 -0
- data/ruby/neo4j/driver/internal/internal_session.rb +81 -0
- data/ruby/neo4j/driver/internal/internal_transaction.rb +48 -0
- data/ruby/neo4j/driver/internal/logging/channel_activity_logger.rb +29 -0
- data/ruby/neo4j/driver/internal/logging/channel_error_logger.rb +17 -0
- data/ruby/neo4j/driver/internal/logging/prefixed_logger.rb +19 -0
- data/ruby/neo4j/driver/internal/logging/reformatted_logger.rb +17 -0
- data/ruby/neo4j/driver/internal/messaging/abstract_message_writer.rb +23 -0
- data/ruby/neo4j/driver/internal/messaging/bolt_protocol.rb +30 -0
- data/ruby/neo4j/driver/internal/messaging/bolt_protocol_version.rb +46 -0
- data/ruby/neo4j/driver/internal/messaging/common/common_message_reader.rb +51 -0
- data/ruby/neo4j/driver/internal/messaging/common/common_value.rb +31 -0
- data/ruby/neo4j/driver/internal/messaging/common/common_value_packer.rb +101 -0
- data/ruby/neo4j/driver/internal/messaging/common/common_value_unpacker.rb +234 -0
- data/ruby/neo4j/driver/internal/messaging/encode/begin_message_encoder.rb +15 -0
- data/ruby/neo4j/driver/internal/messaging/encode/commit_message_encoder.rb +14 -0
- data/ruby/neo4j/driver/internal/messaging/encode/discard_all_message_encoder.rb +14 -0
- data/ruby/neo4j/driver/internal/messaging/encode/discard_message_encoder.rb +15 -0
- data/ruby/neo4j/driver/internal/messaging/encode/goodbye_message_encoder.rb +14 -0
- data/ruby/neo4j/driver/internal/messaging/encode/hello_message_encoder.rb +15 -0
- data/ruby/neo4j/driver/internal/messaging/encode/init_message_encoder.rb +16 -0
- data/ruby/neo4j/driver/internal/messaging/encode/pull_all_message_encoder.rb +14 -0
- data/ruby/neo4j/driver/internal/messaging/encode/pull_message_encoder.rb +15 -0
- data/ruby/neo4j/driver/internal/messaging/encode/reset_message_encoder.rb +14 -0
- data/ruby/neo4j/driver/internal/messaging/encode/rollback_message_encoder.rb +14 -0
- data/ruby/neo4j/driver/internal/messaging/encode/route_message_encoder.rb +18 -0
- data/ruby/neo4j/driver/internal/messaging/encode/route_v44_message_encoder.rb +27 -0
- data/ruby/neo4j/driver/internal/messaging/encode/run_message_encoder.rb +16 -0
- data/ruby/neo4j/driver/internal/messaging/encode/run_with_metadata_message_encoder.rb +17 -0
- data/ruby/neo4j/driver/internal/messaging/request/abstract_streaming_message.rb +22 -0
- data/ruby/neo4j/driver/internal/messaging/request/begin_message.rb +26 -0
- data/ruby/neo4j/driver/internal/messaging/request/commit_message.rb +20 -0
- data/ruby/neo4j/driver/internal/messaging/request/discard_all_message.rb +20 -0
- data/ruby/neo4j/driver/internal/messaging/request/discard_message.rb +23 -0
- data/ruby/neo4j/driver/internal/messaging/request/goodbye_message.rb +20 -0
- data/ruby/neo4j/driver/internal/messaging/request/hello_message.rb +31 -0
- data/ruby/neo4j/driver/internal/messaging/request/init_message.rb +19 -0
- data/ruby/neo4j/driver/internal/messaging/request/message_with_metadata.rb +10 -0
- data/ruby/neo4j/driver/internal/messaging/request/multi_database_util.rb +26 -0
- data/ruby/neo4j/driver/internal/messaging/request/pull_all_message.rb +23 -0
- data/ruby/neo4j/driver/internal/messaging/request/pull_message.rb +22 -0
- data/ruby/neo4j/driver/internal/messaging/request/reset_message.rb +32 -0
- data/ruby/neo4j/driver/internal/messaging/request/rollback_message.rb +20 -0
- data/ruby/neo4j/driver/internal/messaging/request/route_message.rb +33 -0
- data/ruby/neo4j/driver/internal/messaging/request/run_message.rb +23 -0
- data/ruby/neo4j/driver/internal/messaging/request/run_with_metadata_message.rb +47 -0
- data/ruby/neo4j/driver/internal/messaging/request/transaction_metadata_builder.rb +24 -0
- data/ruby/neo4j/driver/internal/messaging/response/failure_message.rb +40 -0
- data/ruby/neo4j/driver/internal/messaging/response/ignored_message.rb +29 -0
- data/ruby/neo4j/driver/internal/messaging/response/record_message.rb +33 -0
- data/ruby/neo4j/driver/internal/messaging/response/success_message.rb +34 -0
- data/ruby/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +78 -0
- data/ruby/neo4j/driver/internal/messaging/v3/message_format_v3.rb +17 -0
- data/ruby/neo4j/driver/internal/messaging/v3/message_writer_v3.rb +27 -0
- data/ruby/neo4j/driver/internal/messaging/v4/bolt_protocol_v4.rb +29 -0
- data/ruby/neo4j/driver/internal/messaging/v4/message_format_v4.rb +17 -0
- data/ruby/neo4j/driver/internal/messaging/v4/message_writer_v4.rb +28 -0
- data/ruby/neo4j/driver/internal/messaging/v41/bolt_protocol_v41.rb +25 -0
- data/ruby/neo4j/driver/internal/messaging/v42/bolt_protocol_v42.rb +13 -0
- data/ruby/neo4j/driver/internal/messaging/v43/bolt_protocol_v43.rb +19 -0
- data/ruby/neo4j/driver/internal/messaging/v43/message_format_v43.rb +18 -0
- data/ruby/neo4j/driver/internal/messaging/v43/message_writer_v43.rb +34 -0
- data/ruby/neo4j/driver/internal/messaging/v44/bolt_protocol_v44.rb +17 -0
- data/ruby/neo4j/driver/internal/messaging/v44/message_format_v44.rb +18 -0
- data/ruby/neo4j/driver/internal/messaging/v44/message_writer_v44.rb +26 -0
- data/ruby/neo4j/driver/internal/metrics/connection_pool_metrics_listener.rb +34 -0
- data/ruby/neo4j/driver/internal/metrics/internal_abstract_metrics.rb +46 -0
- data/ruby/neo4j/driver/internal/metrics/internal_connection_pool_metrics.rb +105 -0
- data/ruby/neo4j/driver/internal/metrics/internal_metrics.rb +82 -0
- data/ruby/neo4j/driver/internal/metrics/internal_metrics_provider.rb +18 -0
- data/ruby/neo4j/driver/internal/metrics/listener_event.rb +17 -0
- data/ruby/neo4j/driver/internal/metrics/metrics_provider.rb +24 -0
- data/ruby/neo4j/driver/internal/metrics/time_recorder_listener_event.rb +15 -0
- data/ruby/neo4j/driver/internal/packstream/byte_array_incompatible_packer.rb +12 -0
- data/ruby/neo4j/driver/internal/packstream/pack_input.rb +47 -0
- data/ruby/neo4j/driver/internal/packstream/pack_output.rb +39 -0
- data/ruby/neo4j/driver/internal/packstream/pack_stream.rb +326 -0
- data/ruby/neo4j/driver/internal/packstream/pack_type.rb +17 -0
- data/ruby/neo4j/driver/internal/retry/exponential_backoff_retry_logic.rb +151 -0
- data/ruby/neo4j/driver/internal/revocation_strategy.rb +19 -0
- data/ruby/neo4j/driver/internal/scheme.rb +32 -0
- data/ruby/neo4j/driver/internal/security/internal_auth_token.rb +15 -0
- data/ruby/neo4j/driver/internal/security/security_plan_impl.rb +43 -0
- data/ruby/neo4j/driver/internal/security_setting.rb +66 -0
- data/ruby/neo4j/driver/internal/session_factory_impl.rb +32 -0
- data/ruby/neo4j/driver/internal/spi/connection.rb +19 -0
- data/ruby/neo4j/driver/internal/spi/connection_pool.rb +9 -0
- data/ruby/neo4j/driver/internal/spi/response_handler.rb +23 -0
- data/ruby/neo4j/driver/internal/summary/internal_database_info.rb +7 -0
- data/ruby/neo4j/driver/internal/summary/internal_input_position.rb +11 -0
- data/ruby/neo4j/driver/internal/summary/internal_notification.rb +16 -0
- data/ruby/neo4j/driver/internal/summary/internal_plan.rb +41 -0
- data/ruby/neo4j/driver/internal/summary/internal_profiled_plan.rb +32 -0
- data/ruby/neo4j/driver/internal/summary/internal_result_summary.rb +33 -0
- data/ruby/neo4j/driver/internal/summary/internal_server_info.rb +6 -0
- data/ruby/neo4j/driver/internal/summary/internal_summary_counters.rb +18 -0
- data/ruby/neo4j/driver/internal/svm/netty_substitutions.rb +196 -0
- data/ruby/neo4j/driver/internal/svm/z_lib_substitutions.rb +21 -0
- data/ruby/neo4j/driver/internal/util/certificate_tool.rb +65 -0
- data/ruby/neo4j/driver/internal/util/clock.rb +29 -0
- data/ruby/neo4j/driver/internal/util/error_util.rb +104 -0
- data/ruby/neo4j/driver/internal/util/extract.rb +123 -0
- data/ruby/neo4j/driver/internal/util/format.rb +39 -0
- data/ruby/neo4j/driver/internal/util/futures.rb +99 -0
- data/ruby/neo4j/driver/internal/util/iterables.rb +35 -0
- data/ruby/neo4j/driver/internal/util/lock_util.rb +23 -0
- data/ruby/neo4j/driver/internal/util/metadata_extractor.rb +109 -0
- data/ruby/neo4j/driver/internal/util/mutex.rb +9 -0
- data/ruby/neo4j/driver/internal/util/preconditions.rb +16 -0
- data/ruby/neo4j/driver/internal/util/server_version.rb +60 -0
- data/ruby/neo4j/driver/logging1.rb +51 -0
- data/ruby/neo4j/driver/net/server_address1.rb +9 -0
- data/ruby/neo4j/driver/query.rb +48 -0
- data/ruby/neo4j/driver/records.rb +13 -0
- data/ruby/neo4j/driver/session_config.rb +15 -0
- data/ruby/neo4j/driver/transaction_config.rb +46 -0
- data/ruby/neo4j/driver/values.rb +26 -0
- data/{lib → ruby}/neo4j/driver/version.rb +1 -1
- data/ruby/neo4j/driver.rb +30 -0
- metadata +267 -92
- data/ffi/bolt/address.rb +0 -11
- data/ffi/bolt/address_resolver.rb +0 -12
- data/ffi/bolt/address_set.rb +0 -9
- data/ffi/bolt/auth.rb +0 -10
- data/ffi/bolt/auto_releasable.rb +0 -22
- data/ffi/bolt/boolean.rb +0 -9
- data/ffi/bolt/bytes.rb +0 -10
- data/ffi/bolt/config.rb +0 -45
- data/ffi/bolt/connection.rb +0 -44
- data/ffi/bolt/connector.rb +0 -17
- data/ffi/bolt/dictionary.rb +0 -15
- data/ffi/bolt/error.rb +0 -74
- data/ffi/bolt/float.rb +0 -9
- data/ffi/bolt/integer.rb +0 -9
- data/ffi/bolt/library.rb +0 -12
- data/ffi/bolt/lifecycle.rb +0 -9
- data/ffi/bolt/list.rb +0 -10
- data/ffi/bolt/log.rb +0 -16
- data/ffi/bolt/socket_options.rb +0 -14
- data/ffi/bolt/status.rb +0 -25
- data/ffi/bolt/string.rb +0 -9
- data/ffi/bolt/structure.rb +0 -10
- data/ffi/bolt/value.rb +0 -35
- data/ffi/neo4j/driver/auth_tokens.rb +0 -18
- data/ffi/neo4j/driver/config.rb +0 -40
- data/ffi/neo4j/driver/graph_database.rb +0 -52
- data/ffi/neo4j/driver/internal/async/access_mode_connection.rb +0 -19
- data/ffi/neo4j/driver/internal/async/direct_connection.rb +0 -106
- data/ffi/neo4j/driver/internal/bolt_server_address.rb +0 -18
- data/ffi/neo4j/driver/internal/bookmarks_holder.rb +0 -30
- data/ffi/neo4j/driver/internal/direct_connection_provider.rb +0 -28
- data/ffi/neo4j/driver/internal/driver_factory.rb +0 -126
- data/ffi/neo4j/driver/internal/error_handling.rb +0 -112
- data/ffi/neo4j/driver/internal/explicit_transaction.rb +0 -146
- data/ffi/neo4j/driver/internal/handlers/pull_all_response_handler.rb +0 -104
- data/ffi/neo4j/driver/internal/handlers/response_handler.rb +0 -49
- data/ffi/neo4j/driver/internal/handlers/run_response_handler.rb +0 -32
- data/ffi/neo4j/driver/internal/handlers/session_pull_all_response_handler.rb +0 -32
- data/ffi/neo4j/driver/internal/handlers/transaction_pull_all_response_handler.rb +0 -23
- data/ffi/neo4j/driver/internal/internal_driver.rb +0 -45
- data/ffi/neo4j/driver/internal/internal_logger.rb +0 -32
- data/ffi/neo4j/driver/internal/internal_resolver.rb +0 -31
- data/ffi/neo4j/driver/internal/internal_statement_result.rb +0 -52
- data/ffi/neo4j/driver/internal/messaging/bolt_protocol.rb +0 -24
- data/ffi/neo4j/driver/internal/messaging/v1/bolt_protocol_v1.rb +0 -59
- data/ffi/neo4j/driver/internal/messaging/v2/bolt_protocol_v2.rb +0 -16
- data/ffi/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +0 -63
- data/ffi/neo4j/driver/internal/network_session.rb +0 -129
- data/ffi/neo4j/driver/internal/retry/exponential_backoff_retry_logic.rb +0 -80
- data/ffi/neo4j/driver/internal/session_factory_impl.rb +0 -28
- data/ffi/neo4j/driver/internal/summary/internal_result_summary.rb +0 -67
- data/ffi/neo4j/driver/internal/summary/internal_server_info.rb +0 -19
- data/ffi/neo4j/driver/internal/summary/internal_summary_counters.rb +0 -23
- data/ffi/neo4j/driver/internal/util/metadata_extractor.rb +0 -15
- data/ffi/neo4j/driver/internal/value/base_time_value.rb +0 -22
- data/ffi/neo4j/driver/internal/value/date_value.rb +0 -25
- data/ffi/neo4j/driver/internal/value/duration_value.rb +0 -27
- data/ffi/neo4j/driver/internal/value/local_date_time_value.rb +0 -24
- data/ffi/neo4j/driver/internal/value/local_time_value.rb +0 -19
- data/ffi/neo4j/driver/internal/value/node_value.rb +0 -18
- data/ffi/neo4j/driver/internal/value/offset_time_value.rb +0 -25
- data/ffi/neo4j/driver/internal/value/path_value.rb +0 -41
- data/ffi/neo4j/driver/internal/value/point2_d_value.rb +0 -24
- data/ffi/neo4j/driver/internal/value/point3_d_value.rb +0 -24
- data/ffi/neo4j/driver/internal/value/relationship_value.rb +0 -18
- data/ffi/neo4j/driver/internal/value/structure_value.rb +0 -42
- data/ffi/neo4j/driver/internal/value/time_with_zone_id_value.rb +0 -25
- data/ffi/neo4j/driver/internal/value/time_with_zone_offset_value.rb +0 -28
- data/ffi/neo4j/driver/internal/value/unbound_relationship_value.rb +0 -18
- data/ffi/neo4j/driver/internal/value/value_adapter.rb +0 -101
- data/ffi/neo4j/driver/net/server_address.rb +0 -13
- data/ffi/neo4j/driver/statement.rb +0 -15
- data/ffi/neo4j/driver/types/entity.rb +0 -21
- data/ffi/neo4j/driver/types/node.rb +0 -16
- data/ffi/neo4j/driver/types/path.rb +0 -35
- data/ffi/neo4j/driver/types/relationship.rb +0 -19
- data/ffi/neo4j/driver.rb +0 -61
- data/lib/neo4j/driver/internal/ruby_signature.rb +0 -18
@@ -0,0 +1,110 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
module Cursor
|
4
|
+
class RxResultCursorImpl
|
5
|
+
DISCARD_RECORD_CONSUMER = -> (record, throwable) {}
|
6
|
+
|
7
|
+
delegate :cancel, to: :@pull_handler
|
8
|
+
delegate :done?, to: :@summary_future
|
9
|
+
|
10
|
+
def initialize(run_error, run_handler, pull_handler)
|
11
|
+
java.util.Objects.require_non_null(run_handler)
|
12
|
+
java.util.Objects.require_non_null(pull_handler)
|
13
|
+
|
14
|
+
@run_response_error = run_error
|
15
|
+
@run_handler = @run_handler
|
16
|
+
@pull_handler = @pull_handler
|
17
|
+
@summary_future = java.util.concurrent.CompletableFuture.new
|
18
|
+
@consumer_status = RecordConsumerStatus::NOT_INSTALLED
|
19
|
+
install_summary_consumer
|
20
|
+
end
|
21
|
+
|
22
|
+
def keys
|
23
|
+
@run_handler.query_keys.keys
|
24
|
+
end
|
25
|
+
|
26
|
+
def install_record_consumer(record_consumer)
|
27
|
+
raise Util::ErrorUtil.new_result_consumed_error if result_consumed
|
28
|
+
|
29
|
+
return if @consumer_status.installed?
|
30
|
+
|
31
|
+
@consumer_status = record_consumer == DISCARD_RECORD_CONSUMER ? RecordConsumerStatus::DISCARD_INSTALLED : RecordConsumerStatus::INSTALLED
|
32
|
+
@pull_handler.install_record_consumer(record_consumer)
|
33
|
+
assert_run_completed_successfully
|
34
|
+
end
|
35
|
+
|
36
|
+
def request(n)
|
37
|
+
n = -1 if n == java.lang.Long::MAX_VALUE
|
38
|
+
|
39
|
+
@pull_handler.request(n)
|
40
|
+
end
|
41
|
+
|
42
|
+
def discard_all_failure_async
|
43
|
+
# calling this method will enforce discarding record stream and finish running cypher query
|
44
|
+
summary_stage.then_apply(-> (_summary) { nil }).exceptionally do |throwable|
|
45
|
+
@summary_future_exposed ? null : throwable
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def pull_all_failure_async
|
50
|
+
if @consumer_status.installed? && !done?
|
51
|
+
return java.util.concurrent.CompletableFuture.completed_future(Exceptions::TransactionNestingException.new("You cannot run another query or begin a new transaction in the same session before you've fully consumed the previous run result."))
|
52
|
+
end
|
53
|
+
|
54
|
+
# It is safe to discard records as either the streaming has not started at all, or the streaming is fully finished.
|
55
|
+
discard_all_failure_async
|
56
|
+
end
|
57
|
+
|
58
|
+
def summary_async
|
59
|
+
@summary_future_exposed = true
|
60
|
+
summary_stage
|
61
|
+
end
|
62
|
+
|
63
|
+
def summary_stage
|
64
|
+
unless done? && @result_consumed # the summary is called before record streaming
|
65
|
+
install_record_consumer(DISCARD_RECORD_CONSUMER)
|
66
|
+
cancel
|
67
|
+
@result_consumed = true
|
68
|
+
end
|
69
|
+
|
70
|
+
@summary_future
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def assert_run_completed_successfully
|
76
|
+
unless @run_response_error.nil?
|
77
|
+
@pull_handler.on_failure(@run_response_error)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def install_summary_consumer
|
82
|
+
@pull_handler.install_summary_consumer do |summary, error|
|
83
|
+
if !error.nil? && @consumer_status.discard_consumer?
|
84
|
+
# We will only report the error to summary if there is no user record consumer installed
|
85
|
+
# When a user record consumer is installed, the error will be reported to record consumer instead.
|
86
|
+
@summary_future.complete_exceptionally(error)
|
87
|
+
elsif !summary.nil?
|
88
|
+
@summary_future.complete(summary)
|
89
|
+
end
|
90
|
+
|
91
|
+
# else (nil, nil) to indicate a has_more success
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class RecordConsumerStatus
|
96
|
+
attr_reader :installed, :discard_consumer
|
97
|
+
|
98
|
+
def initialize(installed, discard_consumer)
|
99
|
+
@installed = installed
|
100
|
+
@discard_consumer = discard_consumer
|
101
|
+
end
|
102
|
+
|
103
|
+
NOT_INSTALLED = new(false, false)
|
104
|
+
INSTALLED = new(true, false)
|
105
|
+
DISCARD_INSTALLED = new(true, true)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
class DatabaseNameUtil
|
4
|
+
DEFAULT_DATABASE_NAME = nil
|
5
|
+
SYSTEM_DATABASE_NAME = 'system'
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
DEFAULT_DATABASE = Struct.new(:database_name, :description).new(nil, '<default database>')
|
10
|
+
SYSTEM_DATABASE = InternalDatabaseName.new(SYSTEM_DATABASE_NAME)
|
11
|
+
|
12
|
+
public
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def default_database
|
16
|
+
DEFAULT_DATABASE
|
17
|
+
end
|
18
|
+
|
19
|
+
def system_database
|
20
|
+
SYSTEM_DATABASE
|
21
|
+
end
|
22
|
+
|
23
|
+
def database(name)
|
24
|
+
case name
|
25
|
+
when DEFAULT_DATABASE_NAME
|
26
|
+
default_database
|
27
|
+
when SYSTEM_DATABASE_NAME
|
28
|
+
system_database
|
29
|
+
else
|
30
|
+
InternalDatabaseName.new(name)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
class DefaultBookmarkHolder
|
4
|
+
attr_reader :bookmark
|
5
|
+
|
6
|
+
def initialize(bookmark = InternalBookmark.empty)
|
7
|
+
@bookmark = bookmark
|
8
|
+
end
|
9
|
+
|
10
|
+
def bookmark=(bookmark)
|
11
|
+
@bookmark = bookmark if bookmark.present?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
class DirectConnectionProvider
|
4
|
+
attr_reader :address
|
5
|
+
|
6
|
+
def initialize(address, connection_pool)
|
7
|
+
@address = address
|
8
|
+
@connection_pool = connection_pool
|
9
|
+
end
|
10
|
+
|
11
|
+
delegate :close, to: :@connection_pool
|
12
|
+
|
13
|
+
def acquire_connection(context)
|
14
|
+
database_name = context.database_name || DatabaseNameUtil::DEFAULT_DATABASE
|
15
|
+
Async::Connection::DirectConnection.new(private_acquire_connection, database_name, context.mode,
|
16
|
+
context.impersonated_user)
|
17
|
+
end
|
18
|
+
|
19
|
+
def verify_connectivity
|
20
|
+
private_acquire_connection&.release
|
21
|
+
end
|
22
|
+
|
23
|
+
def supports_multi_db?
|
24
|
+
private_acquire_connection.then do |conn|
|
25
|
+
supports_multi_database?(conn)
|
26
|
+
ensure
|
27
|
+
conn.release
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# Used only for grabbing a connection with the server after hello message.
|
34
|
+
# This connection cannot be directly used for running any queries as it is missing necessary connection context
|
35
|
+
def private_acquire_connection
|
36
|
+
@connection_pool.acquire(@address)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Neo4j::Driver::Internal
|
2
|
+
class DriverFactory
|
3
|
+
include Scheme
|
4
|
+
NO_ROUTING_CONTEXT_ERROR_MESSAGE = "Routing parameters are not supported with scheme 'bolt'. Given URI: "
|
5
|
+
|
6
|
+
def initialize(domain_name_resolver = ->(name) { [name] })
|
7
|
+
@domain_name_resolver = domain_name_resolver
|
8
|
+
end
|
9
|
+
|
10
|
+
def new_instance(uri, auth_token, routing_settings, retry_settings, config, security_plan, event_loop_group = nil)
|
11
|
+
bootstrap = create_bootstrap(
|
12
|
+
**event_loop_group ? { event_loop_group: event_loop_group } : { thread_count: config[:event_loop_threads] }
|
13
|
+
)
|
14
|
+
|
15
|
+
address = BoltServerAddress.new(uri: uri)
|
16
|
+
new_routing_settings = routing_settings.with_routing_context(Cluster::RoutingContext.new(uri))
|
17
|
+
|
18
|
+
# org.neo4j.driver.internal.shaded.io.netty.util.internal.logging.InternalLoggerFactory.setDefaultFactory(org.neo4j.driver.internal.logging.NettyLogging.new(config.logging))
|
19
|
+
_event_executor_group = nil #bootstrap.group
|
20
|
+
retry_logic = Retry::ExponentialBackoffRetryLogic.new(retry_settings, _event_executor_group, config[:logger])
|
21
|
+
|
22
|
+
metrics_provider = create_driver_metrics(config)
|
23
|
+
connection_pool = create_connection_pool(auth_token, security_plan, bootstrap, metrics_provider, config,
|
24
|
+
event_loop_group.nil?, new_routing_settings.routing_context)
|
25
|
+
|
26
|
+
create_driver(uri, security_plan, address, connection_pool, _event_executor_group, new_routing_settings, retry_logic, metrics_provider, config)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def create_connection_pool(auth_token, security_plan, bootstrap, metrics_provider, config, owns_event_loop_group, routing_context)
|
32
|
+
clock = Util::Clock::System
|
33
|
+
settings = ConnectionSettings.new(auth_token, config[:user_agent], config[:connection_timeout].in_milliseconds)
|
34
|
+
connector = create_connector(settings, security_plan, config, clock, routing_context)
|
35
|
+
pool_settings = Async::Pool::PoolSettings.new(
|
36
|
+
config[:max_connection_pool_size],
|
37
|
+
config[:connection_acquisition_timeout],
|
38
|
+
config[:max_connection_lifetime].in_milliseconds,
|
39
|
+
config[:idle_time_before_connection_test]&.in_milliseconds || -1 # TODO: remember to get rid of -1
|
40
|
+
)
|
41
|
+
Async::Pool::ConnectionPoolImpl.new(connector, pool_settings, config[:logger])
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_driver_metrics(config)
|
45
|
+
if config[:metrics_enabled]
|
46
|
+
Metrics::InternalMetricsProvider.new(config[:logger])
|
47
|
+
else
|
48
|
+
Metrics::MetricsProvider::METRICS_DISABLED_PROVIDER
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_resolver(config)
|
53
|
+
config[:resolver] || ->(address) { [address] }
|
54
|
+
end
|
55
|
+
|
56
|
+
def assert_no_routing_context(uri, routing_settings)
|
57
|
+
routing_context = routing_settings.routing_context
|
58
|
+
if routing_context.defined?
|
59
|
+
raise ArgumentError, "Routing parameters are not supported with scheme 'bolt'. Given URI: '#{uri}'"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_connector(settings, security_plan, config, clock, routing_context)
|
64
|
+
Async::Connection::ChannelConnectorImpl.new(
|
65
|
+
settings, security_plan, config[:logger], clock, routing_context, &method(:domain_name_resolver))
|
66
|
+
end
|
67
|
+
|
68
|
+
def create_driver(uri, security_plan, address, connection_pool, eventExecutorGroup, routing_settings, retryLogic, metricsProvider, config)
|
69
|
+
if routing_scheme?(uri.scheme.downcase)
|
70
|
+
create_routing_driver(security_plan, address, connection_pool, eventExecutorGroup, routing_settings, retryLogic, metricsProvider, config)
|
71
|
+
else
|
72
|
+
assert_no_routing_context(uri, routing_settings)
|
73
|
+
create_direct_driver(security_plan, address, connection_pool, retryLogic, metricsProvider, config)
|
74
|
+
end
|
75
|
+
rescue => driver_error
|
76
|
+
# we need to close the connection pool if driver creation threw exception
|
77
|
+
close_connection_pool_and_suppress_error(connection_pool, driver_error)
|
78
|
+
raise
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_direct_driver(securityPlan, address, connection_pool, retryLogic, metricsProvider, config)
|
82
|
+
connection_provider = DirectConnectionProvider.new(address, connection_pool)
|
83
|
+
driver(:Direct, securityPlan, address, connection_provider, retryLogic, metricsProvider, config)
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_routing_driver(securityPlan, address, connection_pool, eventExecutorGroup, routingSettings, retryLogic, metricsProvider, config)
|
87
|
+
connection_provider = create_load_balancer(address, connection_pool, eventExecutorGroup, config, routingSettings)
|
88
|
+
driver(:Routing, securityPlan, address, connection_provider, retryLogic, metricsProvider, config)
|
89
|
+
end
|
90
|
+
|
91
|
+
def driver(type, security_plan, address, connection_provider, retry_logic, metrics_provider, config)
|
92
|
+
session_factory = SessionFactoryImpl.new(connection_provider, retry_logic, config)
|
93
|
+
InternalDriver.new(security_plan, session_factory, metrics_provider, config[:logger]).tap do |driver|
|
94
|
+
config[:logger]&.info { "#{type} driver instance #{driver.object_id} created for server address #{address}" }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def create_load_balancer(address, connection_pool, eventExecutorGroup, config, routingSettings)
|
99
|
+
load_balancing_strategy = Cluster::Loadbalancing::LeastConnectedLoadBalancingStrategy.new(connection_pool, config[:logger])
|
100
|
+
resolver = create_resolver(config)
|
101
|
+
Cluster::Loadbalancing::LoadBalancer.new(
|
102
|
+
address, routingSettings, connection_pool, eventExecutorGroup,
|
103
|
+
config[:logger], load_balancing_strategy, resolver, &method(:domain_name_resolver))
|
104
|
+
end
|
105
|
+
|
106
|
+
def create_bootstrap(**args)
|
107
|
+
Async::Connection::BootstrapFactory.new_bootstrap(**args)
|
108
|
+
end
|
109
|
+
|
110
|
+
protected
|
111
|
+
|
112
|
+
def close_connection_pool_and_suppress_error(connection_pool, main_error)
|
113
|
+
connection_pool.close
|
114
|
+
rescue => close_error
|
115
|
+
Util::ErrorUtil.add_suppressed(main_error, close_error)
|
116
|
+
end
|
117
|
+
|
118
|
+
# def getDomainNameResolver(name)
|
119
|
+
# domain_name_resolver(name).map { |addrinfo| java.net.InetAddress.getByName(addrinfo.canonname) }.to_java(java.net.InetAddress)
|
120
|
+
# end
|
121
|
+
|
122
|
+
def domain_name_resolver(name)
|
123
|
+
@domain_name_resolver.call(name).flat_map { |n| Addrinfo.getaddrinfo(n, nil, nil, nil, Socket::IPPROTO_TCP) }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
module Handlers
|
4
|
+
class BeginTxResponseHandler
|
5
|
+
include Spi::ResponseHandler
|
6
|
+
|
7
|
+
def on_success(_metadata)
|
8
|
+
end
|
9
|
+
|
10
|
+
def on_failure(error)
|
11
|
+
raise error
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_record(fields)
|
15
|
+
raise "Transaction begin is not expected to receive records: #{fields}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
module Handlers
|
4
|
+
class ChannelReleasingResetResponseHandler < ResetResponseHandler
|
5
|
+
def initialize(channel, pool, message_dispatcher, clock, release_future)
|
6
|
+
super(message_dispatcher, release_future)
|
7
|
+
@channel = channel
|
8
|
+
@pool = pool
|
9
|
+
@clock = clock
|
10
|
+
end
|
11
|
+
|
12
|
+
def reset_completed(completion_future, success)
|
13
|
+
if success
|
14
|
+
# update the last-used timestamp before returning the channel back to the pool
|
15
|
+
Async::Connection::ChannelAttributes.set_last_used_timestamp(@channel, @clock.millis)
|
16
|
+
closure_stage = Util::Futures.completed_with_null
|
17
|
+
else
|
18
|
+
# close the channel before returning it back to the pool if RESET failed
|
19
|
+
closure_stage = Util::Futures.as_completion_stage(@channel.close)
|
20
|
+
end
|
21
|
+
|
22
|
+
closure_stage.exceptionally(-> (_throwable) { nil }).then_compose(-> (_ignored) { @pool.release(@channel) }).when_complete do |_, _error|
|
23
|
+
completion_future.complete(nil)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
module Handlers
|
4
|
+
class CommitTxResponseHandler
|
5
|
+
include Spi::ResponseHandler
|
6
|
+
|
7
|
+
def initialize(completion_listener)
|
8
|
+
@completion_listener = completion_listener
|
9
|
+
end
|
10
|
+
|
11
|
+
def on_success(metadata)
|
12
|
+
@completion_listener.bookmark = metadata[:bookmark]&.then(&InternalBookmark.method(:parse))
|
13
|
+
end
|
14
|
+
|
15
|
+
def on_failure(error)
|
16
|
+
raise error
|
17
|
+
end
|
18
|
+
|
19
|
+
def on_record(fields)
|
20
|
+
raise "Transaction commit is not expected to receive records: #{fields}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
module Handlers
|
4
|
+
class HelloResponseHandler
|
5
|
+
include Spi::ResponseHandler
|
6
|
+
CONNECTION_ID_METADATA_KEY = :connection_id
|
7
|
+
CONFIGURATION_HINTS_KEY = :hints
|
8
|
+
CONNECTION_RECEIVE_TIMEOUT_SECONDS_KEY = :'connection.recv_timeout_seconds'
|
9
|
+
delegate :attributes, to: :@channel
|
10
|
+
|
11
|
+
def initialize(channel, protocol_version)
|
12
|
+
@channel = channel
|
13
|
+
@protocol_version = protocol_version
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_success(metadata)
|
17
|
+
begin
|
18
|
+
attributes[:server_agent] = Util::MetadataExtractor.extract_server(metadata)
|
19
|
+
# From Server V4 extracting server from metadata in the success message is unreliable
|
20
|
+
# so we fix the Server version against the Bolt Protocol version for Server V4 and above.
|
21
|
+
attributes[:server_version] =
|
22
|
+
if Messaging::V3::BoltProtocolV3::VERSION == @protocol_version
|
23
|
+
Util::MetadataExtractor.extract_neo4j_server_version(metadata)
|
24
|
+
else
|
25
|
+
Util::ServerVersion.from_bolt_protocol_version(@protocol_version)
|
26
|
+
end
|
27
|
+
|
28
|
+
attributes[:connection_id] = extract_connection_id(metadata)
|
29
|
+
process_configuration_hints(metadata)
|
30
|
+
rescue => error
|
31
|
+
on_failure(error)
|
32
|
+
raise error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def on_failure(error)
|
37
|
+
@channel.close
|
38
|
+
raise error ### Not sure about that
|
39
|
+
end
|
40
|
+
|
41
|
+
def on_record(_fields)
|
42
|
+
raise NotImplementedError
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def extract_connection_id(metadata)
|
48
|
+
value = metadata[CONNECTION_ID_METADATA_KEY]
|
49
|
+
|
50
|
+
if value.nil?
|
51
|
+
raise Exceptions::IllegalStateException, "Unable to extract #{CONNECTION_ID_METADATA_KEY} from a response to HELLO message. Received metadata: #{metadata}"
|
52
|
+
end
|
53
|
+
|
54
|
+
value
|
55
|
+
end
|
56
|
+
|
57
|
+
def process_configuration_hints(metadata)
|
58
|
+
metadata[CONFIGURATION_HINTS_KEY]&.dig(CONNECTION_RECEIVE_TIMEOUT_SECONDS_KEY)&.tap do |value|
|
59
|
+
attributes[:connection_read_timeout] = value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Neo4j::Driver
|
2
|
+
module Internal
|
3
|
+
module Handlers
|
4
|
+
class InitResponseHandler
|
5
|
+
include Spi::ResponseHandler
|
6
|
+
|
7
|
+
def initialize(connection_initialized_promise)
|
8
|
+
@connection_initialized_promise = connection_initialized_promise
|
9
|
+
@channel = connection_initialized_promise
|
10
|
+
end
|
11
|
+
|
12
|
+
def on_success(_metadata)
|
13
|
+
begin
|
14
|
+
server_version = Util::MetadataExtractor.extract_neo4j_server_version(metadata)
|
15
|
+
Async::Connection::ChannelAttributes.set_server_version(@channel, server_version)
|
16
|
+
|
17
|
+
@connection_initialized_promise.set_success
|
18
|
+
rescue StandardError => error
|
19
|
+
@connection_initialized_promise.set_failure(error)
|
20
|
+
raise error
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def on_failure(error)
|
25
|
+
@channel.close.add_listener(-> (_future) { @connection_initialized_promise.set_failure(error) })
|
26
|
+
end
|
27
|
+
|
28
|
+
def on_record(fields)
|
29
|
+
raise java.lang.UnsupportedOperationException
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|