neo4j-ruby-driver 4.4.0.alpha.6 → 4.4.0.alpha.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) 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/internal/async/network_session.rb +4 -3
  6. data/ruby/neo4j/driver/internal/async/pool/{netty_channel_tracker.rb → channel_tracker.rb} +6 -8
  7. data/ruby/neo4j/driver/internal/async/pool/connection_pool_impl.rb +3 -3
  8. data/ruby/neo4j/driver/internal/cluster/cluster_composition.rb +10 -20
  9. data/ruby/neo4j/driver/internal/cluster/cluster_composition_lookup_result.rb +2 -2
  10. data/ruby/neo4j/driver/internal/cluster/cluster_routing_table.rb +37 -54
  11. data/ruby/neo4j/driver/internal/cluster/identity_resolver.rb +1 -4
  12. data/ruby/neo4j/driver/internal/cluster/loadbalancing/least_connected_load_balancing_strategy.rb +6 -6
  13. data/ruby/neo4j/driver/internal/cluster/loadbalancing/load_balancer.rb +44 -80
  14. data/ruby/neo4j/driver/internal/cluster/multi_databases_routing_procedure_runner.rb +6 -9
  15. data/ruby/neo4j/driver/internal/cluster/rediscovery_impl.rb +65 -155
  16. data/ruby/neo4j/driver/internal/cluster/route_message_routing_procedure_runner.rb +2 -2
  17. data/ruby/neo4j/driver/internal/cluster/routing_procedure_cluster_composition_provider.rb +8 -12
  18. data/ruby/neo4j/driver/internal/cluster/routing_procedure_response.rb +19 -3
  19. data/ruby/neo4j/driver/internal/cluster/routing_table_handler_impl.rb +46 -67
  20. data/ruby/neo4j/driver/internal/cluster/routing_table_registry_impl.rb +42 -61
  21. data/ruby/neo4j/driver/internal/cluster/single_database_routing_procedure_runner.rb +8 -10
  22. data/ruby/neo4j/driver/internal/cursor/async_result_cursor_impl.rb +2 -1
  23. data/ruby/neo4j/driver/internal/cursor/disposable_async_result_cursor.rb +11 -14
  24. data/ruby/neo4j/driver/internal/database_name_util.rb +3 -3
  25. data/ruby/neo4j/driver/internal/default_bookmark_holder.rb +1 -7
  26. data/ruby/neo4j/driver/internal/direct_connection_provider.rb +1 -1
  27. data/ruby/neo4j/driver/internal/driver_factory.rb +4 -4
  28. data/ruby/neo4j/driver/internal/handlers/legacy_pull_all_response_handler.rb +34 -24
  29. data/ruby/neo4j/driver/internal/impersonation_util.rb +2 -2
  30. data/ruby/neo4j/driver/internal/internal_bookmark.rb +1 -1
  31. data/ruby/neo4j/driver/internal/internal_database_name.rb +3 -5
  32. data/ruby/neo4j/driver/internal/messaging/bolt_protocol_version.rb +3 -1
  33. data/ruby/neo4j/driver/internal/messaging/encode/route_message_encoder.rb +8 -2
  34. data/ruby/neo4j/driver/internal/messaging/encode/route_v44_message_encoder.rb +8 -13
  35. data/ruby/neo4j/driver/internal/messaging/request/begin_message.rb +2 -3
  36. data/ruby/neo4j/driver/internal/messaging/request/multi_database_util.rb +2 -2
  37. data/ruby/neo4j/driver/internal/messaging/request/route_message.rb +5 -10
  38. data/ruby/neo4j/driver/internal/messaging/request/run_with_metadata_message.rb +5 -3
  39. data/ruby/neo4j/driver/internal/messaging/request/transaction_metadata_builder.rb +2 -2
  40. data/ruby/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +1 -1
  41. data/ruby/neo4j/driver/internal/messaging/v44/message_writer_v44.rb +1 -1
  42. data/ruby/neo4j/driver/internal/read_only_bookmark_holder.rb +13 -0
  43. data/ruby/neo4j/driver/internal/resolved_bolt_server_address.rb +35 -0
  44. data/ruby/neo4j/driver/internal/security/security_plan_impl.rb +14 -9
  45. data/ruby/neo4j/driver/internal/util/error_util.rb +1 -1
  46. data/ruby/neo4j/driver/net/{server_address1.rb → server_address.rb} +2 -2
  47. data/ruby/neo4j/driver/query.rb +1 -1
  48. data/ruby/neo4j/driver/transaction_config.rb +5 -1
  49. data/ruby/neo4j/driver/values.rb +3 -3
  50. data/ruby/neo4j/driver/version.rb +1 -1
  51. metadata +6 -5
  52. data/ruby/neo4j/driver/internal/database_name.rb +0 -12
@@ -9,7 +9,7 @@ module Neo4j::Driver
9
9
  class << self
10
10
  def auto_commit_tx_run_message(query, config, database_name, mode, bookmark, impersonated_user)
11
11
  metadata = Request::TransactionMetadataBuilder.build_metadata(
12
- tx_timeout: config[:timeout], tx_metadata: config[:metadata], database_name: database_name, mode: mode,
12
+ timeout: config[:timeout], tx_metadata: config[:metadata], database_name: database_name, mode: mode,
13
13
  bookmark: bookmark, impersonated_user: impersonated_user)
14
14
  new(query.text, query.parameters, metadata)
15
15
  end
@@ -29,10 +29,12 @@ module Neo4j::Driver
29
29
  SIGNATURE
30
30
  end
31
31
 
32
- def eql?(other)
33
- super && query.eql?(other.query) && parameters.eql?(other.parameters)
32
+ def ==(other)
33
+ super && query == other.query && parameters == other.parameters
34
34
  end
35
35
 
36
+ alias eql? ==
37
+
36
38
  def hash
37
39
  [query, parameters, metadata].hash
38
40
  end
@@ -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)
@@ -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
+ private 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)
@@ -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.6'
5
+ VERSION = '4.4.0.alpha.7'
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.6
4
+ version: 4.4.0.alpha.7
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-28 00:00:00.000000000 Z
11
+ date: 2022-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -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
@@ -468,7 +469,7 @@ files:
468
469
  - ruby/neo4j/driver/internal/util/preconditions.rb
469
470
  - ruby/neo4j/driver/internal/util/server_version.rb
470
471
  - ruby/neo4j/driver/logging1.rb
471
- - ruby/neo4j/driver/net/server_address1.rb
472
+ - ruby/neo4j/driver/net/server_address.rb
472
473
  - ruby/neo4j/driver/query.rb
473
474
  - ruby/neo4j/driver/records.rb
474
475
  - 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