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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/neo4j/driver/exceptions/protocol_exception.rb +2 -2
  4. data/lib/neo4j/driver/internal/bolt_server_address.rb +6 -6
  5. data/lib/neo4j/driver/types/time.rb +4 -2
  6. data/ruby/neo4j/driver/config.rb +1 -1
  7. data/ruby/neo4j/driver/internal/async/inbound/inbound_message_dispatcher.rb +1 -1
  8. data/ruby/neo4j/driver/internal/async/network_connection.rb +15 -22
  9. data/ruby/neo4j/driver/internal/async/network_session.rb +4 -3
  10. data/ruby/neo4j/driver/internal/async/pool/channel.rb +1 -0
  11. data/ruby/neo4j/driver/internal/async/pool/{netty_channel_tracker.rb → channel_tracker.rb} +6 -8
  12. data/ruby/neo4j/driver/internal/async/pool/connection_pool_impl.rb +4 -3
  13. data/ruby/neo4j/driver/internal/cluster/cluster_composition.rb +10 -20
  14. data/ruby/neo4j/driver/internal/cluster/cluster_composition_lookup_result.rb +2 -2
  15. data/ruby/neo4j/driver/internal/cluster/cluster_routing_table.rb +37 -54
  16. data/ruby/neo4j/driver/internal/cluster/identity_resolver.rb +1 -4
  17. data/ruby/neo4j/driver/internal/cluster/loadbalancing/least_connected_load_balancing_strategy.rb +6 -6
  18. data/ruby/neo4j/driver/internal/cluster/loadbalancing/load_balancer.rb +44 -80
  19. data/ruby/neo4j/driver/internal/cluster/multi_databases_routing_procedure_runner.rb +6 -9
  20. data/ruby/neo4j/driver/internal/cluster/rediscovery_impl.rb +65 -155
  21. data/ruby/neo4j/driver/internal/cluster/route_message_routing_procedure_runner.rb +2 -2
  22. data/ruby/neo4j/driver/internal/cluster/routing_procedure_cluster_composition_provider.rb +8 -12
  23. data/ruby/neo4j/driver/internal/cluster/routing_procedure_response.rb +19 -3
  24. data/ruby/neo4j/driver/internal/cluster/routing_table_handler_impl.rb +46 -67
  25. data/ruby/neo4j/driver/internal/cluster/routing_table_registry_impl.rb +42 -61
  26. data/ruby/neo4j/driver/internal/cluster/single_database_routing_procedure_runner.rb +8 -10
  27. data/ruby/neo4j/driver/internal/cursor/async_result_cursor_impl.rb +2 -1
  28. data/ruby/neo4j/driver/internal/cursor/disposable_async_result_cursor.rb +11 -14
  29. data/ruby/neo4j/driver/internal/database_name_util.rb +3 -3
  30. data/ruby/neo4j/driver/internal/default_bookmark_holder.rb +1 -7
  31. data/ruby/neo4j/driver/internal/direct_connection_provider.rb +1 -1
  32. data/ruby/neo4j/driver/internal/driver_factory.rb +4 -4
  33. data/ruby/neo4j/driver/internal/handlers/channel_releasing_reset_response_handler.rb +11 -10
  34. data/ruby/neo4j/driver/internal/handlers/legacy_pull_all_response_handler.rb +35 -25
  35. data/ruby/neo4j/driver/internal/handlers/pulln/auto_pull_response_handler.rb +1 -2
  36. data/ruby/neo4j/driver/internal/handlers/reset_response_handler.rb +1 -1
  37. data/ruby/neo4j/driver/internal/impersonation_util.rb +2 -2
  38. data/ruby/neo4j/driver/internal/internal_bookmark.rb +1 -1
  39. data/ruby/neo4j/driver/internal/internal_database_name.rb +3 -5
  40. data/ruby/neo4j/driver/internal/internal_driver.rb +1 -1
  41. data/ruby/neo4j/driver/internal/messaging/bolt_protocol_version.rb +3 -1
  42. data/ruby/neo4j/driver/internal/messaging/encode/route_message_encoder.rb +8 -2
  43. data/ruby/neo4j/driver/internal/messaging/encode/route_v44_message_encoder.rb +8 -13
  44. data/ruby/neo4j/driver/internal/messaging/request/begin_message.rb +2 -3
  45. data/ruby/neo4j/driver/internal/messaging/request/multi_database_util.rb +2 -2
  46. data/ruby/neo4j/driver/internal/messaging/request/route_message.rb +5 -10
  47. data/ruby/neo4j/driver/internal/messaging/request/run_with_metadata_message.rb +5 -3
  48. data/ruby/neo4j/driver/internal/messaging/request/transaction_metadata_builder.rb +2 -2
  49. data/ruby/neo4j/driver/internal/messaging/v3/bolt_protocol_v3.rb +1 -1
  50. data/ruby/neo4j/driver/internal/messaging/v44/message_writer_v44.rb +1 -1
  51. data/ruby/neo4j/driver/internal/read_only_bookmark_holder.rb +13 -0
  52. data/ruby/neo4j/driver/internal/resolved_bolt_server_address.rb +35 -0
  53. data/ruby/neo4j/driver/internal/security/security_plan_impl.rb +14 -9
  54. data/ruby/neo4j/driver/internal/util/error_util.rb +1 -1
  55. data/ruby/neo4j/driver/net/{server_address1.rb → server_address.rb} +2 -2
  56. data/ruby/neo4j/driver/query.rb +1 -1
  57. data/ruby/neo4j/driver/transaction_config.rb +5 -1
  58. data/ruby/neo4j/driver/values.rb +3 -3
  59. data/ruby/neo4j/driver/version.rb +1 -1
  60. metadata +11 -24
  61. data/ruby/neo4j/driver/internal/database_name.rb +0 -12
@@ -4,7 +4,6 @@ module Neo4j::Driver
4
4
  # This is the Pull All response handler that handles pull all messages in Bolt v3 and previous protocol versions.
5
5
  class LegacyPullAllResponseHandler
6
6
  include Spi::ResponseHandler
7
- UNINITIALIZED_RECORDS = []
8
7
  RECORD_BUFFER_LOW_WATERMARK = ENV['record_buffer_low_watermark']&.to_i || 300
9
8
  RECORD_BUFFER_HIGH_WATERMARK = ENV['record_buffer_high_watermark']&.to_i || 1000
10
9
 
@@ -14,7 +13,7 @@ module Neo4j::Driver
14
13
  @metadata_extractor = Internal::Validator.require_non_nil!(metadata_extractor)
15
14
  @connection = Internal::Validator.require_non_nil!(connection)
16
15
  @completion_listener = Internal::Validator.require_non_nil!(completion_listener)
17
- @records = UNINITIALIZED_RECORDS
16
+ @records = ::Async::Queue.new
18
17
  end
19
18
 
20
19
  def can_manage_auto_read?
@@ -39,7 +38,7 @@ module Neo4j::Driver
39
38
 
40
39
  failed_record_future = fail_record_future(error)
41
40
 
42
- if fail_record_future
41
+ if failed_record_future
43
42
  # error propagated through the record future
44
43
  complete_failure_future(nil)
45
44
  else
@@ -54,7 +53,7 @@ module Neo4j::Driver
54
53
  if @ignore_records
55
54
  complete_record_future(nil)
56
55
  else
57
- record = InternalRecord.new(run_response_handler.query_keys, fields)
56
+ record = InternalRecord.new(@run_response_handler.query_keys, fields)
58
57
  enqueue_record(record)
59
58
  complete_record_future(record)
60
59
  end
@@ -65,36 +64,46 @@ module Neo4j::Driver
65
64
  end
66
65
 
67
66
  def peek_async
68
- record = @records.first
67
+ while @records.empty? && !(@ignore_records || @finished)
68
+ @records.wait
69
+ end
70
+ @records.items.first
69
71
 
70
- if record.nil?
71
- return Util::Futures.failed_future(extract_failure) unless @failure.nil?
72
+ # if record.nil?
73
+ # return Util::Futures.failed_future(extract_failure) unless @failure.nil?
72
74
 
73
- return Util::Futures.completed_with_null if @ignore_records || @finished
75
+ # return Util::Futures.completed_with_null if @ignore_records || @finished
74
76
 
75
- @record_future = java.util.concurrent.CompletableFuture.new if @record_future.nil?
77
+ # @record_future = java.util.concurrent.CompletableFuture.new if @record_future.nil?
76
78
 
77
- @record_future
78
- else
79
- java.util.concurrent.CompletableFuture.completed_future(record)
80
- end
79
+ # @record_future
80
+ # else
81
+ # # java.util.concurrent.CompletableFuture.completed_future(record)
82
+ # record
83
+ # end
81
84
  end
82
85
 
83
86
  def next_async
84
- peek_async.then_apply(-> (_ignore) { dequeue_record })
87
+ dequeue_record if peek_async
85
88
  end
86
89
 
87
90
  def consume_async
88
91
  @ignore_records = true
89
- @records.clear
90
-
91
- pull_all_failure_async.then_apply do |error|
92
- unless error.nil?
93
- raise Util::Futures.as_completion_exception, error
94
- end
92
+ @records.items.clear
95
93
 
94
+ if pull_all_failure_async.nil?
96
95
  @summary
96
+ else
97
+ raise Util::Futures.as_completion_exception, pull_all_failure_async
97
98
  end
99
+
100
+ # pull_all_failure_async do |error|
101
+ # unless error.nil?
102
+ # raise Util::Futures.as_completion_exception, error
103
+ # end
104
+
105
+ # @summary
106
+ # end
98
107
  end
99
108
 
100
109
  def list_async(map_function)
@@ -115,7 +124,8 @@ module Neo4j::Driver
115
124
  if !@failure.nil?
116
125
  return java.util.concurrent.CompletableFuture.completed_future(extract_failure)
117
126
  elsif @finished
118
- return Util::Futures.completed_with_null
127
+ return nil
128
+ # return Util::Futures.completed_with_null
119
129
  else
120
130
  if @failure_future.nil?
121
131
  # neither SUCCESS nor FAILURE message has arrived, register future to be notified when it arrives
@@ -139,7 +149,7 @@ module Neo4j::Driver
139
149
  # when failure is requested we have to buffer all remaining records and then return the error
140
150
  # do not disable auto-read in this case, otherwise records will not be consumed and trailing
141
151
  # SUCCESS or FAILURE message will not arrive as well, so callers will get stuck waiting for the error
142
- if !should_buffer_all_records && records.size > RECORD_BUFFER_HIGH_WATERMARK
152
+ if !should_buffer_all_records && @records.size > RECORD_BUFFER_HIGH_WATERMARK
143
153
  # more than high watermark records are already queued, tell connection to stop auto-reading from network
144
154
  # this is needed to deal with slow consumers, we do not want to buffer all records in memory if they are
145
155
  # fetched from network faster than consumed
@@ -148,7 +158,7 @@ module Neo4j::Driver
148
158
  end
149
159
 
150
160
  def dequeue_record
151
- record = @records.drop(1)
161
+ record = @records.dequeue
152
162
 
153
163
  if @records.size < RECORD_BUFFER_LOW_WATERMARK
154
164
  # less than low watermark records are now available in the buffer, tell connection to pre-fetch more
@@ -170,7 +180,7 @@ module Neo4j::Driver
170
180
  result << map_function.apply(record)
171
181
  end
172
182
 
173
- @records.clear
183
+ @records.items.clear
174
184
  result
175
185
  end
176
186
 
@@ -212,7 +222,7 @@ module Neo4j::Driver
212
222
 
213
223
  def extract_result_summary(metadata)
214
224
  result_available_after = @run_response_handler.result_available_after
215
- @metadataExtractor.extract_summary(@query, @connection, result_available_after, metadata)
225
+ @metadata_extractor.extract_summary(@query, @connection, result_available_after, metadata)
216
226
  end
217
227
 
218
228
  def enable_auto_read
@@ -4,7 +4,6 @@ module Neo4j::Driver
4
4
  module Pulln
5
5
  class AutoPullResponseHandler < BasicPullResponseHandler
6
6
  delegate :signal, to: :@records
7
- UNINITIALIZED_RECORDS = ::Async::Queue.new
8
7
  LONG_MAX_VALUE = 2 ** 63 - 1
9
8
 
10
9
  def initialize(query, run_response_handler, connection, metadata_extractor, completion_listener, fetch_size)
@@ -20,7 +19,7 @@ module Neo4j::Driver
20
19
  @low_record_watermark = fetch_size * 0.3
21
20
  end
22
21
 
23
- @records = UNINITIALIZED_RECORDS
22
+ @records = ::Async::Queue.new
24
23
  @auto_pull_enabled = true
25
24
 
26
25
  install_record_and_summary_consumers
@@ -9,7 +9,7 @@ module Neo4j::Driver
9
9
  @completion_future = completion_future
10
10
  end
11
11
 
12
- def on_success(_metadata)
12
+ def on_success(_metadata = {})
13
13
  reset_completed(true)
14
14
  end
15
15
 
@@ -14,8 +14,8 @@ module Neo4j::Driver
14
14
  private
15
15
 
16
16
  def self.supports_impersonation?(connection)
17
- connection.server_version.greater_than_or_equal(Util::ServerVersion::V4_4_0) &&
18
- connection.protocol.version.compare_to( Messaging::V44::BoltProtocolV44::VERSION ) >= 0
17
+ connection.server_version >= Util::ServerVersion::V4_4_0 &&
18
+ connection.protocol.version >= Messaging::V44::BoltProtocolV44::VERSION
19
19
  end
20
20
  end
21
21
  end
@@ -2,13 +2,13 @@ module Neo4j::Driver
2
2
  module Internal
3
3
  class InternalBookmark
4
4
  include Bookmark
5
- EMPTY = new
6
5
  attr :values
7
6
  delegate :hash, :empty?, to: :values
8
7
 
9
8
  private def initialize(*values)
10
9
  @values = values.to_set
11
10
  end
11
+ EMPTY = new.freeze
12
12
 
13
13
  def ==(other)
14
14
  equal?(other) || self.class == other.class && values == other.values
@@ -1,10 +1,8 @@
1
1
  module Neo4j::Driver
2
2
  module Internal
3
- class InternalDatabaseName < Struct.new(:database_name)
4
- alias description database_name
5
-
6
- def initialize(database_name)
7
- super(Validator.require_non_nil!(database_name))
3
+ class InternalDatabaseName < Struct.new(:database_name, :description)
4
+ def initialize(database_name: nil, description: database_name)
5
+ super(database_name, description)
8
6
  end
9
7
  end
10
8
  end
@@ -7,7 +7,7 @@ module Neo4j::Driver
7
7
  # delegate :verify_connectivity, to: :session_factory
8
8
  delegate :metrics, :metrics_enabled?, to: :metrics_provider
9
9
  auto_closable :session
10
- sync :close, :supports_multi_db?, :verify_connectivity
10
+ sync :close, :supports_multi_db?, :verify_connectivity, :session
11
11
 
12
12
  def initialize(security_plan, session_factory, metrics_provider, logger)
13
13
  @closed = Concurrent::AtomicBoolean.new(false)
@@ -2,10 +2,12 @@ module Neo4j::Driver
2
2
  module Internal
3
3
  module Messaging
4
4
  class BoltProtocolVersion < Struct.new(:major_version, :minor_version)
5
+ include Comparable
6
+
5
7
  def self.from_raw_bytes(raw_version)
6
8
  major = raw_version & 0x000000FF
7
9
  minor = (raw_version >> 8) & 0x000000FF
8
- new(major,minor)
10
+ new(major, minor)
9
11
  end
10
12
 
11
13
  def to_int
@@ -8,8 +8,14 @@ module Neo4j::Driver
8
8
  Util::Preconditions.check_argument(message, Request::RouteMessage)
9
9
  packer.pack_struct_header(3, message.signature)
10
10
  packer.pack(message.routing_context)
11
- packer.pack(message.bookmark.present? ? Values.value(message.bookmark.values) : Values.value(java.util.Collections.empty_list))
12
- packer.pack(message.database_name)
11
+ packer.pack(message.bookmark&.values || [])
12
+ packer.pack(option(message))
13
+ end
14
+
15
+ private
16
+
17
+ def option(message)
18
+ message.database_name
13
19
  end
14
20
  end
15
21
  end
@@ -3,22 +3,17 @@ module Neo4j::Driver
3
3
  module Messaging
4
4
  module Encode
5
5
  # Encodes the ROUTE message to the stream
6
- class RouteV44MessageEncoder
7
- def encode(message, packer)
8
- Util::Preconditions.check_argument(message, Request::RouteMessage)
9
- packer.pack_struct_header(3, message.signature)
10
- packer.pack(message.routing_context)
11
- packer.pack(message.bookmark.present? ? Values.value(message.bookmark.values) : Values.value(java.util.Collections.empty_list))
6
+ class RouteV44MessageEncoder < RouteMessageEncoder
7
+ private
12
8
 
13
- if !message.impersonated_user.nil? && message.database_name.nil?
14
- params = java.util.Collections.singleton_map("imp_user", Values.value(message.impersonated_user))
15
- elsif !message.database_name.nil?
16
- params = java.util.Collections.singleton_map("db", Values.value(message.database_name))
9
+ def option(message)
10
+ if message.impersonated_user && !message.database_name
11
+ { imp_user: message.impersonated_user }
12
+ elsif message.database_name
13
+ { db: message.database_name }
17
14
  else
18
- params = java.util.Collections.empty_map
15
+ {}
19
16
  end
20
-
21
- packer.pack(params)
22
17
  end
23
18
  end
24
19
  end
@@ -7,9 +7,8 @@ module Neo4j::Driver
7
7
 
8
8
  def initialize(bookmark, config, database_name, mode, impersonated_user)
9
9
  super(Request::TransactionMetadataBuilder.build_metadata(
10
- tx_timeout: config[:timeout]&.then(&DurationNormalizer.method(:milliseconds)),
11
- tx_metadata: config[:metadata], database_name: database_name, mode: mode, bookmark: bookmark,
12
- impersonated_user: impersonated_user))
10
+ timeout: config[:timeout], tx_metadata: config[:metadata], database_name: database_name, mode: mode,
11
+ bookmark: bookmark, impersonated_user: impersonated_user))
13
12
  end
14
13
 
15
14
  def signature
@@ -10,12 +10,12 @@ module Neo4j::Driver
10
10
  end
11
11
  end
12
12
 
13
- def supports_multi_database(connection)
13
+ def supports_multi_database?(connection)
14
14
  connection.server_version >= Util::ServerVersion::V4_0_0 &&
15
15
  connection.protocol.version >= V4::BoltProtocolV4::VERSION
16
16
  end
17
17
 
18
- def supports_route_message(connection)
18
+ def supports_route_message?(connection)
19
19
  connection.protocol.version >= V43::BoltProtocolV43::VERSION
20
20
  end
21
21
  end
@@ -6,19 +6,14 @@ module Neo4j::Driver
6
6
  # instance can provide the wanted service.
7
7
  # <p>
8
8
  # This message is used to fetch this routing information.
9
+ #
10
+ # @param routingContext The routing context used to define the routing table. Multi-datacenter deployments is one of its use cases.
11
+ # @param bookmark The bookmark used when getting the routing table.
12
+ # @param databaseName The name of the database to get the routing table for.
13
+ # @param impersonatedUser The name of the impersonated user to get the routing table for, should be {@code null} for non-impersonated requests
9
14
  class RouteMessage < Struct.new(:routing_context, :bookmark, :database_name, :impersonated_user)
10
15
  SIGNATURE = 0x66
11
16
 
12
- # Constructor
13
-
14
- # @param routingContext The routing context used to define the routing table. Multi-datacenter deployments is one of its use cases.
15
- # @param bookmark The bookmark used when getting the routing table.
16
- # @param databaseName The name of the database to get the routing table for.
17
- # @param impersonatedUser The name of the impersonated user to get the routing table for, should be {@code null} for non-impersonated requests
18
- def initialize(routing_context, bookmark, database_name, impersonated_user)
19
- super(routing_context.freeze, bookmark, database_name, impersonated_user)
20
- end
21
-
22
17
  def signature
23
18
  SIGNATURE
24
19
  end
@@ -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.4'
5
+ VERSION = '4.4.0.alpha.7'
6
6
  end
7
7
  end