neo4j-ruby-driver 4.4.0.alpha.5 → 4.4.0.alpha.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/neo4j/driver/exceptions/protocol_exception.rb +2 -2
  3. data/lib/neo4j/driver/internal/bolt_server_address.rb +6 -6
  4. data/lib/neo4j/driver/types/time.rb +4 -2
  5. data/ruby/neo4j/driver/config.rb +1 -1
  6. data/ruby/neo4j/driver/graph_database.rb +2 -2
  7. data/ruby/neo4j/driver/internal/async/inbound/inbound_message_dispatcher.rb +2 -3
  8. data/ruby/neo4j/driver/internal/async/network_session.rb +4 -3
  9. data/ruby/neo4j/driver/internal/async/pool/{netty_channel_tracker.rb → channel_tracker.rb} +6 -8
  10. data/ruby/neo4j/driver/internal/async/pool/connection_pool_impl.rb +3 -3
  11. data/ruby/neo4j/driver/internal/async/unmanaged_transaction.rb +18 -20
  12. data/ruby/neo4j/driver/internal/cluster/cluster_composition.rb +10 -20
  13. data/ruby/neo4j/driver/internal/cluster/cluster_composition_lookup_result.rb +2 -2
  14. data/ruby/neo4j/driver/internal/cluster/cluster_routing_table.rb +38 -55
  15. data/ruby/neo4j/driver/internal/cluster/identity_resolver.rb +1 -4
  16. data/ruby/neo4j/driver/internal/cluster/loadbalancing/least_connected_load_balancing_strategy.rb +6 -6
  17. data/ruby/neo4j/driver/internal/cluster/loadbalancing/load_balancer.rb +44 -80
  18. data/ruby/neo4j/driver/internal/cluster/multi_databases_routing_procedure_runner.rb +6 -9
  19. data/ruby/neo4j/driver/internal/cluster/rediscovery_impl.rb +65 -155
  20. data/ruby/neo4j/driver/internal/cluster/route_message_routing_procedure_runner.rb +2 -2
  21. data/ruby/neo4j/driver/internal/cluster/routing_procedure_cluster_composition_provider.rb +8 -12
  22. data/ruby/neo4j/driver/internal/cluster/routing_procedure_response.rb +19 -3
  23. data/ruby/neo4j/driver/internal/cluster/routing_table_handler_impl.rb +46 -67
  24. data/ruby/neo4j/driver/internal/cluster/routing_table_registry_impl.rb +42 -61
  25. data/ruby/neo4j/driver/internal/cluster/single_database_routing_procedure_runner.rb +15 -19
  26. data/ruby/neo4j/driver/internal/cursor/async_result_cursor_impl.rb +31 -19
  27. data/ruby/neo4j/driver/internal/cursor/disposable_async_result_cursor.rb +12 -15
  28. data/ruby/neo4j/driver/internal/database_name_util.rb +3 -3
  29. data/ruby/neo4j/driver/internal/default_bookmark_holder.rb +1 -7
  30. data/ruby/neo4j/driver/internal/direct_connection_provider.rb +1 -1
  31. data/ruby/neo4j/driver/internal/driver_factory.rb +4 -4
  32. data/ruby/neo4j/driver/internal/handlers/commit_tx_response_handler.rb +4 -4
  33. data/ruby/neo4j/driver/internal/handlers/legacy_pull_all_response_handler.rb +90 -51
  34. data/ruby/neo4j/driver/internal/handlers/pulln/auto_pull_response_handler.rb +33 -44
  35. data/ruby/neo4j/driver/internal/handlers/rollback_tx_response_handler.rb +7 -1
  36. data/ruby/neo4j/driver/internal/impersonation_util.rb +2 -2
  37. data/ruby/neo4j/driver/internal/internal_bookmark.rb +1 -1
  38. data/ruby/neo4j/driver/internal/internal_database_name.rb +3 -5
  39. data/ruby/neo4j/driver/internal/internal_result.rb +5 -5
  40. data/ruby/neo4j/driver/internal/internal_session.rb +1 -1
  41. data/ruby/neo4j/driver/internal/internal_transaction.rb +4 -4
  42. data/ruby/neo4j/driver/internal/messaging/bolt_protocol_version.rb +3 -1
  43. data/ruby/neo4j/driver/internal/messaging/encode/route_message_encoder.rb +8 -2
  44. data/ruby/neo4j/driver/internal/messaging/encode/route_v44_message_encoder.rb +8 -13
  45. data/ruby/neo4j/driver/internal/messaging/request/abstract_streaming_message.rb +4 -1
  46. data/ruby/neo4j/driver/internal/messaging/request/begin_message.rb +2 -3
  47. data/ruby/neo4j/driver/internal/messaging/request/multi_database_util.rb +2 -2
  48. data/ruby/neo4j/driver/internal/messaging/request/route_message.rb +5 -10
  49. data/ruby/neo4j/driver/internal/messaging/request/run_with_metadata_message.rb +5 -3
  50. data/ruby/neo4j/driver/internal/messaging/request/transaction_metadata_builder.rb +2 -2
  51. data/ruby/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +8 -4
  52. data/ruby/neo4j/driver/internal/messaging/v44/message_writer_v44.rb +1 -1
  53. data/ruby/neo4j/driver/internal/read_only_bookmark_holder.rb +13 -0
  54. data/ruby/neo4j/driver/internal/resolved_bolt_server_address.rb +35 -0
  55. data/ruby/neo4j/driver/internal/security/security_plan_impl.rb +14 -9
  56. data/ruby/neo4j/driver/internal/util/error_util.rb +1 -1
  57. data/ruby/neo4j/driver/internal/util/result_holder.rb +70 -0
  58. data/ruby/neo4j/driver/net/{server_address1.rb → server_address.rb} +2 -2
  59. data/ruby/neo4j/driver/query.rb +1 -1
  60. data/ruby/neo4j/driver/transaction_config.rb +5 -1
  61. data/ruby/neo4j/driver/values.rb +3 -3
  62. data/ruby/neo4j/driver/version.rb +1 -1
  63. metadata +16 -14
  64. data/ruby/neo4j/driver/internal/database_name.rb +0 -12
@@ -6,10 +6,10 @@ module Neo4j::Driver
6
6
  MODE_READ_VALUE = 'r'
7
7
 
8
8
  class << self
9
- def build_metadata(tx_timeout:, tx_metadata:, mode:, bookmark:, impersonated_user:,
9
+ def build_metadata(timeout:, tx_metadata:, mode:, bookmark:, impersonated_user:,
10
10
  database_name: DatabaseNameUtil.default_database)
11
11
  { bookmarks: bookmark.presence,
12
- tx_timeout: tx_timeout,
12
+ tx_timeout: timeout&.then(&DurationNormalizer.method(:milliseconds)),
13
13
  tx_metadata: tx_metadata.presence,
14
14
  mode: (MODE_READ_VALUE if mode == AccessMode::READ),
15
15
  db: database_name&.database_name,
@@ -13,7 +13,7 @@ module Neo4j::Driver
13
13
 
14
14
  def initialize_channel(channel, user_agent, auth_token, routing_context)
15
15
  message = Request::HelloMessage.new(user_agent, auth_token,
16
- (routing_context.to_map if routing_context.server_routing_enabled?))
16
+ (routing_context.to_h if routing_context.server_routing_enabled?))
17
17
  handler = Handlers::HelloResponseHandler.new(channel, VERSION)
18
18
 
19
19
  channel.message_dispatcher.enqueue(handler)
@@ -36,12 +36,16 @@ module Neo4j::Driver
36
36
  connection.write_and_flush(begin_message, Handlers::BeginTxResponseHandler.new)
37
37
  end
38
38
 
39
- def commit_transaction(connection, bookmark_holder)
40
- connection.write_and_flush(Request::CommitMessage::COMMIT, Handlers::CommitTxResponseHandler.new(bookmark_holder))
39
+ def commit_transaction(connection)
40
+ Util::ResultHolder.new.tap do |result_holder|
41
+ connection.write_and_flush(Request::CommitMessage::COMMIT, Handlers::CommitTxResponseHandler.new(result_holder))
42
+ end
41
43
  end
42
44
 
43
45
  def rollback_transaction(connection)
44
- connection.write_and_flush(Request::RollbackMessage::ROLLBACK, Handlers::RollbackTxResponseHandler.new)
46
+ Util::ResultHolder.new.tap do |result_holder|
47
+ connection.write_and_flush(Request::RollbackMessage::ROLLBACK, Handlers::RollbackTxResponseHandler.new(result_holder))
48
+ end
45
49
  end
46
50
 
47
51
  def run_in_auto_commit_transaction(connection, query, bookmark_holder, config, fetch_size)
@@ -10,7 +10,7 @@ module Neo4j::Driver
10
10
  Request::HelloMessage::SIGNATURE => Encode::HelloMessageEncoder.new,
11
11
  Request::GoodbyeMessage::SIGNATURE => Encode::GoodbyeMessageEncoder.new,
12
12
  Request::RunWithMetadataMessage::SIGNATURE => Encode::RunWithMetadataMessageEncoder.new,
13
- Request::RouteMessage::SIGNATURE => Encode::RouteMessageEncoder.new,
13
+ Request::RouteMessage::SIGNATURE => Encode::RouteV44MessageEncoder.new,
14
14
  Request::DiscardMessage::SIGNATURE => Encode::DiscardMessageEncoder.new,
15
15
  Request::PullMessage::SIGNATURE => Encode::PullMessageEncoder.new,
16
16
  Request::BeginMessage::SIGNATURE => Encode::BeginMessageEncoder.new,
@@ -0,0 +1,13 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class ReadOnlyBookmarkHolder
4
+ attr_reader :bookmark
5
+
6
+ def initialize(bookmark = InternalBookmark.empty)
7
+ @bookmark = bookmark
8
+ end
9
+
10
+ def bookmark=(_value) end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ class ResolvedBoltServerAddress < BoltServerAddress
4
+ MAX_HOST_ADDRESSES_IN_STRING_VALUE = 5
5
+
6
+ def initialize(host, port, *resolved_addresses_arr)
7
+ super(host: host, port: port)
8
+ if resolved_addresses_arr.empty?
9
+ raise ArgumentError,
10
+ 'The resolvedAddressesArr must not be empty, check your DomainNameResolver is compliant with the interface contract'
11
+ end
12
+ @resolved_addresses = resolved_addresses_arr.to_set.freeze
13
+ @string_value = create_string_representation
14
+ end
15
+
16
+ def unicast_stream
17
+ @resolved_addresses
18
+ .map { |address| BoltServerAddress.new(host: host, connection_host: address.ip_address, port: port) }
19
+ end
20
+
21
+ def to_s
22
+ @string_value
23
+ end
24
+
25
+ def attributes
26
+ super + [@resolved_addresses]
27
+ end
28
+
29
+ def create_string_representation
30
+ host_addresses = @resolved_addresses.take(MAX_HOST_ADDRESSES_IN_STRING_VALUE).map(&:ip_address).join(',')
31
+ "#{host}(#{host_addresses}#{',...' if @resolved_addresses.size > MAX_HOST_ADDRESSES_IN_STRING_VALUE}):#{port}"
32
+ end
33
+ end
34
+ end
35
+ end
@@ -4,7 +4,7 @@ module Neo4j::Driver::Internal
4
4
  :revocation_strategy)
5
5
  class << self
6
6
  def for_all_certificates(requires_hostname_verification, revocation_strategy)
7
- new(true, OpenSSL::SSL::SSLContext.new, requires_hostname_verification, revocation_strategy)
7
+ new(true, all_context(requires_hostname_verification), requires_hostname_verification, revocation_strategy)
8
8
  end
9
9
 
10
10
  def for_custom_ca_signed_certificates(cert_files, requires_hostname_verification, revocation_strategy)
@@ -23,19 +23,24 @@ module Neo4j::Driver::Internal
23
23
 
24
24
  private
25
25
 
26
+ def all_context(requires_hostname_verification)
27
+ ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE, verify_hostname: requires_hostname_verification)
28
+ end
29
+
26
30
  def ca_signed_context(requires_hostname_verification)
27
- OpenSSL::SSL::SSLContext.new.tap do |context|
28
- context.verify_mode = OpenSSL::SSL::VERIFY_PEER
29
- context.verify_hostname = requires_hostname_verification
30
- end
31
+ ssl_context(verify_hostname: requires_hostname_verification)
31
32
  end
32
33
 
33
34
  def custom_ca_signed_context(cert_files, requires_hostname_verification)
34
- ca_signed_context(requires_hostname_verification).tap do |context|
35
- context.cert_store = OpenSSL::X509::Store.new.tap do |store|
35
+ ssl_context(
36
+ cert_store: OpenSSL::X509::Store.new.tap do |store|
36
37
  cert_files.each(&store.method(:add_file))
37
- end
38
- end
38
+ end,
39
+ verify_hostname: requires_hostname_verification)
40
+ end
41
+
42
+ def ssl_context(**params)
43
+ OpenSSL::SSL::SSLContext.new.tap { |context| context.set_params(params) }
39
44
  end
40
45
  end
41
46
  end
@@ -59,7 +59,7 @@ module Neo4j::Driver::Internal::Util
59
59
  end
60
60
 
61
61
  def add_suppressed(main_error, error)
62
- main_error.add_suppressed(error) if main_error.is_a?(Exceptions::Neo4jException) && main_error != error
62
+ main_error.add_suppressed(error) if main_error.is_a?(Neo4j::Driver::Exceptions::Neo4jException) && main_error != error
63
63
  end
64
64
 
65
65
  def get_root_cause(error)
@@ -0,0 +1,70 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Util
4
+ class ResultHolder
5
+ def self.successful(result = nil)
6
+ new.tap { |holder| holder.succeed(result) }
7
+ end
8
+
9
+ def self.failed(error)
10
+ new.tap { |holder| holder.fail(error) }
11
+ end
12
+
13
+ def succeed(result = nil)
14
+ if @completed
15
+ false
16
+ else
17
+ @result = result
18
+ true
19
+ end
20
+ ensure
21
+ @completed = true
22
+ end
23
+
24
+ def fail(error)
25
+ if @completed
26
+ false
27
+ else
28
+ @error = error
29
+ true
30
+ end
31
+ ensure
32
+ @completed = true
33
+ end
34
+
35
+ def result!
36
+ raise @error if @error
37
+ @result
38
+ end
39
+
40
+ def then
41
+ @error ? self : ResultHolder.successful(yield(@result))
42
+ end
43
+
44
+ # &block returns a ResultHolder
45
+ def compose
46
+ @error ? self : yield(@result)
47
+ end
48
+
49
+ def chain
50
+ ResultHolder.successful(yield(@result, @error))
51
+ rescue => error
52
+ ResultHolder.failed(error)
53
+ end
54
+
55
+ def side
56
+ yield(@result, @error)
57
+ self
58
+ end
59
+
60
+ def copy_to(result_holder)
61
+ if @error
62
+ result_holder.fail(@error)
63
+ else
64
+ result_holder.succeed(@result)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,8 +1,8 @@
1
1
  module Neo4j::Driver
2
2
  module Net
3
- module ServerAddress1
3
+ module ServerAddress
4
4
  def self.of(host, port)
5
- Internal::BoltServerAddress.new(host, port)
5
+ Internal::BoltServerAddress.new(host: host, port: port)
6
6
  end
7
7
  end
8
8
  end
@@ -10,7 +10,7 @@ module Neo4j
10
10
  # @since 1.0
11
11
  class Query < Struct.new(:text, :parameters)
12
12
  def initialize(text, **parameters)
13
- super(self.class.validated_query_text(text), Values.value!(parameters))
13
+ super(self.class.validated_query_text(text), Values.value(parameters))
14
14
  end
15
15
 
16
16
  # @param newText the new query text
@@ -32,7 +32,11 @@ module Neo4j
32
32
  def initialize(timeout: nil, metadata: {})
33
33
  Internal::Util::Preconditions.check_argument(timeout.nil? || timeout.positive?, 'Transaction timeout should be positive')
34
34
  Internal::Validator.require_non_nil!(metadata)
35
- merge(timeout: timeout, metadata: metadata)
35
+ merge!(timeout: timeout, metadata: metadata)
36
+ end
37
+
38
+ def self.empty
39
+ EMPTY
36
40
  end
37
41
 
38
42
  # Check if this configuration object contains any values.
@@ -1,14 +1,14 @@
1
1
  module Neo4j
2
2
  module Driver
3
3
  module Values
4
- def self.value!(value)
5
- this_method = method(:value!)
4
+ def self.value(value)
5
+ this_method = method(:value)
6
6
  case value
7
7
  when nil, TrueClass, FalseClass, Integer, Float, String, Symbol, Bookmark, ActiveSupport::Duration,
8
8
  Types::Point, Types::Time, Time, Date
9
9
  value
10
10
  when Hash
11
- value.transform_keys!(&this_method).transform_values!(&this_method)
11
+ value.transform_keys(&this_method).transform_values(&this_method)
12
12
  when Internal::InternalPath
13
13
  nonconvertible(value)
14
14
  when Enumerable
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neo4j
4
4
  module Driver
5
- VERSION = '4.4.0.alpha.5'
5
+ VERSION = '4.4.0.alpha.8'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-ruby-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0.alpha.5
4
+ version: 4.4.0.alpha.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-24 00:00:00.000000000 Z
11
+ date: 2022-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -25,35 +25,35 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: async
28
+ name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.1.10
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.1.10
41
41
  - !ruby/object:Gem::Dependency
42
- name: zeitwerk
42
+ name: async-io
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.10
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.10
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: async-io
56
+ name: async-pool
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,13 +67,13 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: async-pool
70
+ name: async
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
- type: :runtime
76
+ type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
@@ -287,11 +287,11 @@ files:
287
287
  - ruby/neo4j/driver/internal/async/outbound/chunk_aware_byte_buf_output.rb
288
288
  - ruby/neo4j/driver/internal/async/outbound/outbound_message_handler.rb
289
289
  - ruby/neo4j/driver/internal/async/pool/channel.rb
290
+ - ruby/neo4j/driver/internal/async/pool/channel_tracker.rb
290
291
  - ruby/neo4j/driver/internal/async/pool/connection_pool_impl.rb
291
292
  - ruby/neo4j/driver/internal/async/pool/controller.rb
292
293
  - ruby/neo4j/driver/internal/async/pool/netty_channel_health_checker.rb
293
294
  - ruby/neo4j/driver/internal/async/pool/netty_channel_pool.rb
294
- - ruby/neo4j/driver/internal/async/pool/netty_channel_tracker.rb
295
295
  - ruby/neo4j/driver/internal/async/pool/network_connection_factory.rb
296
296
  - ruby/neo4j/driver/internal/async/pool/pool_settings.rb
297
297
  - ruby/neo4j/driver/internal/async/result_cursors_holder.rb
@@ -320,7 +320,6 @@ files:
320
320
  - ruby/neo4j/driver/internal/cursor/disposable_async_result_cursor.rb
321
321
  - ruby/neo4j/driver/internal/cursor/result_cursor_factory_impl.rb
322
322
  - ruby/neo4j/driver/internal/cursor/rx_result_cursor_impl.rb
323
- - ruby/neo4j/driver/internal/database_name.rb
324
323
  - ruby/neo4j/driver/internal/database_name_util.rb
325
324
  - ruby/neo4j/driver/internal/default_bookmark_holder.rb
326
325
  - ruby/neo4j/driver/internal/default_domain_name_resolver.rb
@@ -435,6 +434,8 @@ files:
435
434
  - ruby/neo4j/driver/internal/packstream/pack_output.rb
436
435
  - ruby/neo4j/driver/internal/packstream/pack_stream.rb
437
436
  - ruby/neo4j/driver/internal/packstream/pack_type.rb
437
+ - ruby/neo4j/driver/internal/read_only_bookmark_holder.rb
438
+ - ruby/neo4j/driver/internal/resolved_bolt_server_address.rb
438
439
  - ruby/neo4j/driver/internal/retry/exponential_backoff_retry_logic.rb
439
440
  - ruby/neo4j/driver/internal/revocation_strategy.rb
440
441
  - ruby/neo4j/driver/internal/scheme.rb
@@ -466,9 +467,10 @@ files:
466
467
  - ruby/neo4j/driver/internal/util/metadata_extractor.rb
467
468
  - ruby/neo4j/driver/internal/util/mutex.rb
468
469
  - ruby/neo4j/driver/internal/util/preconditions.rb
470
+ - ruby/neo4j/driver/internal/util/result_holder.rb
469
471
  - ruby/neo4j/driver/internal/util/server_version.rb
470
472
  - ruby/neo4j/driver/logging1.rb
471
- - ruby/neo4j/driver/net/server_address1.rb
473
+ - ruby/neo4j/driver/net/server_address.rb
472
474
  - ruby/neo4j/driver/query.rb
473
475
  - ruby/neo4j/driver/records.rb
474
476
  - ruby/neo4j/driver/session_config.rb
@@ -1,12 +0,0 @@
1
- module Neo4j::Driver
2
- module Internal
3
- class DatabaseName
4
- attr_accessor :database_name, :description
5
-
6
- def initialize(database_name, description = nil)
7
- @database_name = database_name
8
- @description = description
9
- end
10
- end
11
- end
12
- end