neo4j-ruby-driver 4.4.0.alpha.8 → 4.4.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ruby/neo4j/driver/internal/async/network_connection.rb +6 -13
- data/ruby/neo4j/driver/internal/async/network_session.rb +6 -9
- data/ruby/neo4j/driver/internal/async/pool/channel.rb +1 -3
- data/ruby/neo4j/driver/internal/async/pool/connection_pool_impl.rb +2 -2
- data/ruby/neo4j/driver/internal/async/pool/controller.rb +19 -13
- data/ruby/neo4j/driver/internal/async/pool/timed_stack.rb +15 -0
- data/ruby/neo4j/driver/internal/cluster/rediscovery_impl.rb +1 -2
- data/ruby/neo4j/driver/internal/cluster/single_database_routing_procedure_runner.rb +8 -7
- data/ruby/neo4j/driver/internal/cursor/async_result_cursor_impl.rb +1 -2
- data/ruby/neo4j/driver/internal/cursor/async_result_cursor_only_factory.rb +0 -4
- data/ruby/neo4j/driver/internal/cursor/result_cursor_factory_impl.rb +0 -5
- data/ruby/neo4j/driver/internal/handlers/legacy_pull_all_response_handler.rb +10 -80
- data/ruby/neo4j/driver/internal/handlers/pulln/auto_pull_response_handler.rb +3 -2
- data/ruby/neo4j/driver/internal/handlers/pulln/basic_pull_response_handler.rb +28 -18
- data/ruby/neo4j/driver/internal/internal_driver.rb +0 -4
- data/ruby/neo4j/driver/internal/internal_result.rb +1 -12
- data/ruby/neo4j/driver/internal/messaging/abstract_message_writer.rb +1 -1
- data/ruby/neo4j/driver/internal/messaging/v3/message_writer_v3.rb +13 -13
- data/ruby/neo4j/driver/internal/messaging/v4/message_writer_v4.rb +4 -15
- data/ruby/neo4j/driver/internal/messaging/v43/message_writer_v43.rb +2 -16
- data/ruby/neo4j/driver/internal/messaging/v44/message_writer_v44.rb +2 -13
- data/ruby/neo4j/driver/internal/retry/exponential_backoff_retry_logic.rb +1 -1
- data/ruby/neo4j/driver/internal/util/metadata_extractor.rb +1 -3
- data/ruby/neo4j/driver/internal/util/result_holder.rb +2 -0
- data/ruby/neo4j/driver/version.rb +1 -1
- data/ruby/neo4j/driver.rb +1 -2
- metadata +4 -4
- data/ruby/neo4j/driver/session_config.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c795045f581183398e15ba5c44c1f89b10ea234a9a6dc1e46fecd8c02b857bb3
|
4
|
+
data.tar.gz: 1859daea7265d9409d001e748048ab97837fe26895d80fe4e24773b1b51ed49d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f72367997a92a64e8a75ef08bfca59d0acffaac7589e594b69d8fead9173dc3339d6b3dc26ad63ae1f2f0f7cde0a9f172908e9112b92b3496c209ef8c99e01d
|
7
|
+
data.tar.gz: 7bee1a6da116192d42ad2d9b86091d787211af683278c9cfe136f3c8ebf3d1d8c807834b44d5162a308b47b5208ee8e0b40302961a5dfb83c16a7180353d617e
|
@@ -1,14 +1,13 @@
|
|
1
1
|
module Neo4j::Driver
|
2
2
|
module Internal
|
3
3
|
module Async
|
4
|
-
class NetworkConnection
|
4
|
+
class NetworkConnection
|
5
5
|
include Spi::Connection
|
6
6
|
delegate :protocol, to: :@channel
|
7
7
|
|
8
8
|
attr_reader :server_agent, :server_address, :server_version
|
9
9
|
|
10
10
|
def initialize(channel, channel_pool, logger)
|
11
|
-
super()
|
12
11
|
@log = logger
|
13
12
|
@channel = channel
|
14
13
|
@message_dispatcher = channel.attributes[:message_dispatcher]
|
@@ -23,11 +22,6 @@ module Neo4j::Driver
|
|
23
22
|
@status = Concurrent::AtomicReference.new(Status::OPEN)
|
24
23
|
end
|
25
24
|
|
26
|
-
# def close
|
27
|
-
# super
|
28
|
-
# @io.close
|
29
|
-
# end
|
30
|
-
|
31
25
|
def open?
|
32
26
|
@status.get == Status::OPEN
|
33
27
|
end
|
@@ -79,11 +73,10 @@ module Neo4j::Driver
|
|
79
73
|
|
80
74
|
def terminate_and_release(reason)
|
81
75
|
if @status.compare_and_set(Status::OPEN, Status::TERMINATED)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
76
|
+
@channel.attributes[:termination_reason] = reason
|
77
|
+
@channel.close rescue nil
|
78
|
+
@channel_pool.release(@channel)
|
79
|
+
# @metrics_listener.after_connection_released(Connection::ChannelAttributes.pool_id(@channel), @in_use_event)
|
87
80
|
end
|
88
81
|
end
|
89
82
|
|
@@ -96,7 +89,7 @@ module Neo4j::Driver
|
|
96
89
|
# auto-read could've been disabled, re-enable it to automatically receive response for RESET
|
97
90
|
@channel.auto_read = true
|
98
91
|
@message_dispatcher.enqueue(reset_handler)
|
99
|
-
@channel.write_and_flush(Messaging::Request::ResetMessage::RESET)#.add_listener(-> (_future) { register_connection_read_timeout(@channel) })
|
92
|
+
@channel.write_and_flush(Messaging::Request::ResetMessage::RESET) #.add_listener(-> (_future) { register_connection_read_timeout(@channel) })
|
100
93
|
end
|
101
94
|
end
|
102
95
|
|
@@ -22,12 +22,6 @@ module Neo4j::Driver
|
|
22
22
|
new_result_cursor.map_successful_run_completion_async
|
23
23
|
end
|
24
24
|
|
25
|
-
def run_rx(query, **config)
|
26
|
-
new_result_cursor_stage = build_result_cursor_factory(query, config).then_flat(Cursor::ResultCursorFactory.rx_result)
|
27
|
-
@result_cursor_stage = new_result_cursor_stage.rescue {}
|
28
|
-
new_result_cursor_stage
|
29
|
-
end
|
30
|
-
|
31
25
|
def begin_transaction_async(mode = @mode, **config)
|
32
26
|
ensure_session_is_open
|
33
27
|
ensure_no_open_tx_before_starting_tx
|
@@ -67,9 +61,12 @@ module Neo4j::Driver
|
|
67
61
|
def close_async
|
68
62
|
return unless @open.make_false
|
69
63
|
# there exists a cursor with potentially unconsumed error, try to extract and propagate it
|
70
|
-
@result_cursor&.discard_all_failure_async
|
71
|
-
ensure
|
64
|
+
error = @result_cursor&.discard_all_failure_async
|
72
65
|
close_transaction_and_release_connection
|
66
|
+
rescue => tx_close_error
|
67
|
+
error = Util::Futures.combine_errors(error, tx_close_error)
|
68
|
+
ensure
|
69
|
+
raise error if error
|
73
70
|
end
|
74
71
|
|
75
72
|
def current_connection_open?
|
@@ -89,7 +86,7 @@ module Neo4j::Driver
|
|
89
86
|
|
90
87
|
def acquire_connection(mode)
|
91
88
|
# make sure previous result is fully consumed and connection is released back to the pool
|
92
|
-
@result_cursor&.pull_all_failure_async
|
89
|
+
@result_cursor&.pull_all_failure_async&.result!&.then(&method(:raise))
|
93
90
|
if @connection&.open?
|
94
91
|
# there somehow is an existing open connection, this should not happen, just a precondition
|
95
92
|
raise Neo4j::Driver::Exceptions::IllegalStateException.new('Existing open connection detected')
|
@@ -2,14 +2,13 @@ module Neo4j::Driver
|
|
2
2
|
module Internal
|
3
3
|
module Async
|
4
4
|
module Pool
|
5
|
-
class Channel
|
5
|
+
class Channel
|
6
6
|
attr :stream
|
7
7
|
attr_accessor :version, :protocol, :message_format, :message_dispatcher
|
8
8
|
attr :attributes # should be attr
|
9
9
|
attr_accessor :auto_read
|
10
10
|
|
11
11
|
def initialize(address, connector, logger)
|
12
|
-
super()
|
13
12
|
@attributes = Connection::ChannelAttributes.new
|
14
13
|
@stream = Connection::Stream.new(connector.connect(address))
|
15
14
|
@stream.write(Connection::BoltProtocolUtil.handshake_buf)
|
@@ -25,7 +24,6 @@ module Neo4j::Driver
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def close
|
28
|
-
super unless closed? # Should this be conditional?
|
29
27
|
@stream.close
|
30
28
|
end
|
31
29
|
|
@@ -77,7 +77,7 @@ module Neo4j::Driver
|
|
77
77
|
private
|
78
78
|
|
79
79
|
def process_acquisition_error(pool, server_address, error)
|
80
|
-
if error.is_a?(::
|
80
|
+
if error.is_a?(ConnectionPool::TimeoutError)
|
81
81
|
# NettyChannelPool returns future failed with TimeoutException if acquire operation takes more than
|
82
82
|
# configured time, translate this exception to a prettier one and re-throw
|
83
83
|
raise Neo4j::Driver::Exceptions::ClientException.new("Unable to acquire connection from the pool within configured maximum time of #{@settings.connection_acquisition_timeout.inspect}")
|
@@ -109,7 +109,7 @@ module Neo4j::Driver
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def new_pool(address)
|
112
|
-
Controller.
|
112
|
+
Controller.new(limit: @settings.max_connection_pool_size, acquisition_timeout: @settings.connection_acquisition_timeout) { Channel.new(address, @connector, @log) }
|
113
113
|
end
|
114
114
|
|
115
115
|
def get_or_create_pool(address)
|
@@ -2,21 +2,27 @@ module Neo4j::Driver
|
|
2
2
|
module Internal
|
3
3
|
module Async
|
4
4
|
module Pool
|
5
|
-
class Controller <
|
6
|
-
def initialize(
|
7
|
-
super(
|
8
|
-
@
|
5
|
+
class Controller < ConnectionPool
|
6
|
+
def initialize(limit: nil, acquisition_timeout: nil, &block)
|
7
|
+
super(size: limit, timeout: acquisition_timeout, &block)
|
8
|
+
@available = TimedStack.new(@size, &block)
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
def acquire(options = {})
|
12
|
+
@available.pop(options[:timeout] || @timeout)
|
13
|
+
end
|
14
|
+
|
15
|
+
def release(resource)
|
16
|
+
@available.push(resource)
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def close
|
21
|
+
@available.shutdown(&:close)
|
22
|
+
end
|
23
|
+
|
24
|
+
def busy?
|
25
|
+
@available.any_resource_busy?
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -48,8 +48,7 @@ module Neo4j::Driver
|
|
48
48
|
resolved_addresses = @resolver.call(@initial_router).flat_map do |server_address|
|
49
49
|
resolve_all_by_domain_name(server_address).unicast_stream
|
50
50
|
# rescue java.net.UnknownHostException => e
|
51
|
-
rescue => e
|
52
|
-
exception&.add_suppressed(e)
|
51
|
+
rescue SocketError => e
|
53
52
|
exception ||= e
|
54
53
|
[]
|
55
54
|
end
|
@@ -16,9 +16,14 @@ module Neo4j::Driver
|
|
16
16
|
delegate = connection(connection)
|
17
17
|
procedure = procedure_query(connection.server_version, database_name)
|
18
18
|
bookmark_holder = bookmark_holder(bookmark)
|
19
|
-
|
20
|
-
|
21
|
-
.
|
19
|
+
begin
|
20
|
+
records = run_procedure(delegate, procedure, bookmark_holder)
|
21
|
+
RoutingProcedureResponse.new(procedure, records: records)
|
22
|
+
rescue => error
|
23
|
+
handle_error(procedure, error)
|
24
|
+
ensure
|
25
|
+
release_connection(delegate)
|
26
|
+
end
|
22
27
|
end
|
23
28
|
|
24
29
|
private
|
@@ -55,10 +60,6 @@ module Neo4j::Driver
|
|
55
60
|
connection.release
|
56
61
|
end
|
57
62
|
|
58
|
-
def process_procedure_response(procedure, records, error)
|
59
|
-
error ? handle_error(procedure, error) : RoutingProcedureResponse.new(procedure, records: records)
|
60
|
-
end
|
61
|
-
|
62
63
|
def handle_error(procedure, error)
|
63
64
|
if error.is_a? Exceptions::ClientException
|
64
65
|
RoutingProcedureResponse.new(procedure, error: error)
|
@@ -41,8 +41,7 @@ module Neo4j::Driver
|
|
41
41
|
|
42
42
|
def discard_all_failure_async
|
43
43
|
# runError has priority over other errors and is expected to have been reported to user by now
|
44
|
-
consume_async.
|
45
|
-
nil
|
44
|
+
consume_async.error.then { |error| run_error ? nil : error }
|
46
45
|
end
|
47
46
|
|
48
47
|
def pull_all_failure_async
|
@@ -18,10 +18,6 @@ module Neo4j::Driver
|
|
18
18
|
|
19
19
|
DisposableAsyncResultCursor.new(AsyncResultCursorImpl.new(@run_handler, @pull_all_handler))
|
20
20
|
end
|
21
|
-
|
22
|
-
def rx_result
|
23
|
-
Util::Futures.failed_future(Exceptions::ClientException.new('Driver is connected to the database that does not support driver reactive API. In order to use the driver reactive API, please upgrade to neo4j 4.0.0 or later.'))
|
24
|
-
end
|
25
21
|
end
|
26
22
|
end
|
27
23
|
end
|
@@ -18,11 +18,6 @@ module Neo4j::Driver
|
|
18
18
|
|
19
19
|
DisposableAsyncResultCursor.new(AsyncResultCursorImpl.new(@run_handler, @pull_all_handler))
|
20
20
|
end
|
21
|
-
|
22
|
-
def rx_result
|
23
|
-
@connection.write_and_flush(@run_message, @run_handler)
|
24
|
-
@run_future.handle { |_ignored, error| RxResultCursorImpl.new(error, @run_handler, @pull_handler) }
|
25
|
-
end
|
26
21
|
end
|
27
22
|
end
|
28
23
|
end
|
@@ -68,65 +68,21 @@ module Neo4j::Driver
|
|
68
68
|
while @records.empty? && !(@ignore_records || @finished)
|
69
69
|
@records.wait
|
70
70
|
end
|
71
|
-
|
72
|
-
|
73
|
-
Util::ResultHolder.successful(record)
|
74
|
-
|
75
|
-
# if record.nil?
|
76
|
-
# return Util::Futures.failed_future(extract_failure) unless @failure.nil?
|
77
|
-
|
78
|
-
# return Util::Futures.completed_with_null if @ignore_records || @finished
|
79
|
-
|
80
|
-
# @record_future = java.util.concurrent.CompletableFuture.new if @record_future.nil?
|
81
|
-
|
82
|
-
# @record_future
|
83
|
-
# else
|
84
|
-
# # java.util.concurrent.CompletableFuture.completed_future(record)
|
85
|
-
# record
|
86
|
-
# end
|
71
|
+
@records.items.first&.then(&Util::ResultHolder.method(:successful)) or
|
72
|
+
@failure ? Util::ResultHolder.failed(extract_failure) : Util::ResultHolder.successful(nil)
|
87
73
|
end
|
88
74
|
|
89
75
|
def next_async
|
90
|
-
# dequeue_record if peek_async
|
91
76
|
peek_async.then { |record| dequeue_record if record }
|
92
77
|
end
|
93
78
|
|
94
79
|
def consume_async
|
95
80
|
@ignore_records = true
|
96
81
|
@records.items.clear
|
97
|
-
|
98
|
-
# if pull_all_failure_async.nil?
|
99
|
-
# # @summary.then(&Util::ResultHolder.method(:successful))
|
100
|
-
# Util::ResultHolder.successful(@summary)
|
101
|
-
# else
|
102
|
-
# raise pull_all_failure_async
|
103
|
-
# end
|
104
|
-
|
105
|
-
if @failure
|
106
|
-
Util::ResultHolder.failed(extract_failure)
|
107
|
-
else
|
82
|
+
pull_all_failure_async.result!&.then(&Util::ResultHolder.method(:failed)) or
|
108
83
|
Util::ResultHolder.successful(@summary)
|
109
|
-
end
|
110
|
-
|
111
|
-
# pull_all_failure_async do |error|
|
112
|
-
# unless error.nil?
|
113
|
-
# raise Util::Futures.as_completion_exception, error
|
114
|
-
# end
|
115
|
-
|
116
|
-
# @summary
|
117
|
-
# end
|
118
84
|
end
|
119
85
|
|
120
|
-
# def list_async(map_function)
|
121
|
-
# pull_all_failure_async.then_apply do |error|
|
122
|
-
# unless error.nil?
|
123
|
-
# raise Util::Futures.as_completion_exception, error
|
124
|
-
# end
|
125
|
-
|
126
|
-
# records_as_list(map_function)
|
127
|
-
# end
|
128
|
-
# end
|
129
|
-
|
130
86
|
def each
|
131
87
|
pull_all_failure_async.then do
|
132
88
|
unless @finished
|
@@ -141,22 +97,17 @@ module Neo4j::Driver
|
|
141
97
|
end
|
142
98
|
|
143
99
|
def pull_all_failure_async
|
144
|
-
if
|
145
|
-
|
146
|
-
# return java.util.concurrent.CompletableFuture.completed_future(extract_failure)
|
100
|
+
if @failure
|
101
|
+
Util::ResultHolder.successful(extract_failure)
|
147
102
|
elsif @finished
|
148
|
-
|
149
|
-
# return Util::Futures.completed_with_null
|
103
|
+
Util::ResultHolder.successful
|
150
104
|
else
|
151
|
-
|
105
|
+
(@failed_future ||= Util::ResultHolder.new).tap do |_|
|
152
106
|
# neither SUCCESS nor FAILURE message has arrived, register future to be notified when it arrives
|
153
107
|
# future will be completed with null on SUCCESS and completed with Throwable on FAILURE
|
154
108
|
# enable auto-read, otherwise we might not read SUCCESS/FAILURE if records are not consumed
|
155
109
|
enable_auto_read
|
156
|
-
@failure_future = java.util.concurrent.CompletableFuture.new
|
157
110
|
end
|
158
|
-
|
159
|
-
@failure_future
|
160
111
|
end
|
161
112
|
end
|
162
113
|
|
@@ -212,38 +163,17 @@ module Neo4j::Driver
|
|
212
163
|
end
|
213
164
|
|
214
165
|
def complete_record_future(record)
|
215
|
-
# unless @record_future.nil?
|
216
|
-
# future = @record_future
|
217
|
-
# @record_future = nil
|
218
|
-
# future.complete(record)
|
219
|
-
# end
|
220
166
|
@record_future&.succeed(record)
|
221
167
|
@record_future = nil
|
222
168
|
end
|
223
169
|
|
224
170
|
def fail_record_future(error)
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
# future.complete_exceptionally(error)
|
229
|
-
# return true
|
230
|
-
# end
|
231
|
-
|
232
|
-
# false
|
233
|
-
@record_future&.fail(error)
|
234
|
-
ensure
|
235
|
-
@record_future = nil
|
171
|
+
@record_future&.fail(error)
|
172
|
+
ensure
|
173
|
+
@record_future = nil
|
236
174
|
end
|
237
175
|
|
238
176
|
def complete_failure_future(error)
|
239
|
-
# unless @failure_future.nil?
|
240
|
-
# future = @failure_future
|
241
|
-
# @failure_future = nil
|
242
|
-
# future.complete(error)
|
243
|
-
# return true
|
244
|
-
# end
|
245
|
-
|
246
|
-
# false
|
247
177
|
@failure_future&.fail(error)
|
248
178
|
ensure
|
249
179
|
@failure_future = nil
|
@@ -100,8 +100,9 @@ module Neo4j::Driver
|
|
100
100
|
|
101
101
|
def pull_all_async
|
102
102
|
return completed_with_value_if_no_failure(@summary) if done?
|
103
|
-
|
104
|
-
|
103
|
+
(@summary_future ||= Util::ResultHolder.new).tap do |_|
|
104
|
+
request(FetchSizeUtil::UNLIMITED_FETCH_SIZE)
|
105
|
+
end
|
105
106
|
end
|
106
107
|
|
107
108
|
def enqueue_record(record)
|
@@ -99,7 +99,7 @@ module Neo4j::Driver
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def done?
|
102
|
-
@state == State::
|
102
|
+
@state == State::SUCCEEDED_STATE || @state == State::FAILURE_STATE
|
103
103
|
end
|
104
104
|
|
105
105
|
private def extract_result_summary(**metadata)
|
@@ -147,7 +147,7 @@ module Neo4j::Driver
|
|
147
147
|
end
|
148
148
|
|
149
149
|
module State
|
150
|
-
|
150
|
+
class Ready
|
151
151
|
def on_success(context, metadata)
|
152
152
|
context.state = SUCCEEDED_STATE
|
153
153
|
context.complete_with_success(metadata)
|
@@ -171,15 +171,17 @@ module Neo4j::Driver
|
|
171
171
|
context.state = CANCELLED_STATE
|
172
172
|
context.discard_all
|
173
173
|
end
|
174
|
-
end
|
174
|
+
end
|
175
|
+
|
176
|
+
READY_STATE = Ready.new
|
175
177
|
|
176
|
-
|
178
|
+
class Streaming
|
177
179
|
def on_success(context, metadata)
|
178
180
|
if metadata[:has_more]
|
179
181
|
context.state = READY_STATE
|
180
182
|
context.success_has_more
|
181
183
|
else
|
182
|
-
context.state =
|
184
|
+
context.state = SUCCEEDED_STATE
|
183
185
|
context.complete_with_success(metadata)
|
184
186
|
end
|
185
187
|
end
|
@@ -202,15 +204,17 @@ module Neo4j::Driver
|
|
202
204
|
def cancel(context)
|
203
205
|
context.state = CANCELLED_STATE
|
204
206
|
end
|
205
|
-
end
|
207
|
+
end
|
208
|
+
|
209
|
+
STREAMING_STATE = Streaming.new
|
206
210
|
|
207
|
-
|
211
|
+
class Cancelled
|
208
212
|
def on_success(context, metadata)
|
209
213
|
if metadata[:has_more]
|
210
214
|
context.state = CANCELLED_STATE
|
211
215
|
context.discard_all
|
212
216
|
else
|
213
|
-
context.state =
|
217
|
+
context.state = SUCCEEDED_STATE
|
214
218
|
context.complete_with_success(metadata)
|
215
219
|
end
|
216
220
|
end
|
@@ -231,11 +235,13 @@ module Neo4j::Driver
|
|
231
235
|
def cancel(context)
|
232
236
|
context.state = CANCELLED_STATE
|
233
237
|
end
|
234
|
-
end
|
238
|
+
end
|
239
|
+
|
240
|
+
CANCELLED_STATE = Cancelled.new
|
235
241
|
|
236
|
-
|
242
|
+
class Succeeded
|
237
243
|
def on_success(context, metadata)
|
238
|
-
context.state =
|
244
|
+
context.state = SUCCEEDED_STATE
|
239
245
|
context.complete_with_success(metadata)
|
240
246
|
end
|
241
247
|
|
@@ -245,21 +251,23 @@ module Neo4j::Driver
|
|
245
251
|
end
|
246
252
|
|
247
253
|
def on_record(context, _fields)
|
248
|
-
context.state =
|
254
|
+
context.state = SUCCEEDED_STATE
|
249
255
|
end
|
250
256
|
|
251
257
|
def request(context, _n)
|
252
|
-
context.state =
|
258
|
+
context.state = SUCCEEDED_STATE
|
253
259
|
end
|
254
260
|
|
255
261
|
def cancel(context)
|
256
|
-
context.state =
|
262
|
+
context.state = SUCCEEDED_STATE
|
257
263
|
end
|
258
|
-
end
|
264
|
+
end
|
265
|
+
|
266
|
+
SUCCEEDED_STATE = Succeeded.new
|
259
267
|
|
260
|
-
|
268
|
+
class Failed
|
261
269
|
def on_success(context, metadata)
|
262
|
-
context.state =
|
270
|
+
context.state = SUCCEEDED_STATE
|
263
271
|
context.complete_with_success(metadata)
|
264
272
|
end
|
265
273
|
|
@@ -279,7 +287,9 @@ module Neo4j::Driver
|
|
279
287
|
def cancel(context)
|
280
288
|
context.state = FAILURE_STATE
|
281
289
|
end
|
282
|
-
end
|
290
|
+
end
|
291
|
+
|
292
|
+
FAILURE_STATE = Failed.new
|
283
293
|
end
|
284
294
|
end
|
285
295
|
end
|
@@ -21,10 +21,6 @@ module Neo4j::Driver
|
|
21
21
|
InternalSession.new(new_session(**session_config))
|
22
22
|
end
|
23
23
|
|
24
|
-
def rx_session(**session_config)
|
25
|
-
InternalRxSession.new(new_session(**session_config))
|
26
|
-
end
|
27
|
-
|
28
24
|
def async_session(**session_config)
|
29
25
|
InternalAsyncSession.new(new_session(**session_config))
|
30
26
|
end
|
@@ -4,20 +4,13 @@ module Neo4j::Driver
|
|
4
4
|
extend Synchronizable
|
5
5
|
include Enumerable
|
6
6
|
sync :keys, :has_next?, :next, :single, :peek, :consume
|
7
|
+
delegate :keys, to: :@cursor
|
7
8
|
|
8
9
|
def initialize(connection, cursor)
|
9
10
|
@connection = connection
|
10
11
|
@cursor = cursor
|
11
12
|
end
|
12
13
|
|
13
|
-
def keys
|
14
|
-
@keys ||=
|
15
|
-
begin
|
16
|
-
@cursor.peek_async
|
17
|
-
@cursor.keys
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
14
|
def has_next?
|
22
15
|
@cursor.peek_async.result!
|
23
16
|
end
|
@@ -48,10 +41,6 @@ module Neo4j::Driver
|
|
48
41
|
|
49
42
|
private
|
50
43
|
|
51
|
-
def blocking_get(stage)
|
52
|
-
Util::Futures.blocking_get(stage, &method(:terminate_connection_on_thread_interrupt))
|
53
|
-
end
|
54
|
-
|
55
44
|
def terminate_connection_on_thread_interrupt
|
56
45
|
@connection.terminate_and_release('Thread interrupted while waiting for result to arrive')
|
57
46
|
end
|
@@ -4,7 +4,7 @@ module Neo4j::Driver
|
|
4
4
|
class AbstractMessageWriter
|
5
5
|
def initialize(packer)
|
6
6
|
@packer = Internal::Validator.require_non_nil!(packer)
|
7
|
-
@encoders_by_message_signature = Internal::Validator.require_non_nil!(build_encoders)
|
7
|
+
@encoders_by_message_signature = Internal::Validator.require_non_nil!(build_encoders).transform_values(&:new)
|
8
8
|
end
|
9
9
|
|
10
10
|
def write(msg)
|
@@ -3,22 +3,22 @@ module Neo4j::Driver
|
|
3
3
|
module Messaging
|
4
4
|
module V3
|
5
5
|
class MessageWriterV3 < AbstractMessageWriter
|
6
|
+
COMMON_ENCODERS = {
|
7
|
+
Request::HelloMessage::SIGNATURE => Encode::HelloMessageEncoder,
|
8
|
+
Request::GoodbyeMessage::SIGNATURE => Encode::GoodbyeMessageEncoder,
|
9
|
+
Request::RunWithMetadataMessage::SIGNATURE => Encode::RunWithMetadataMessageEncoder,
|
10
|
+
Request::BeginMessage::SIGNATURE => Encode::BeginMessageEncoder,
|
11
|
+
Request::CommitMessage::SIGNATURE => Encode::CommitMessageEncoder,
|
12
|
+
Request::RollbackMessage::SIGNATURE => Encode::RollbackMessageEncoder,
|
13
|
+
Request::ResetMessage::SIGNATURE => Encode::ResetMessageEncoder,
|
14
|
+
}
|
6
15
|
private
|
7
16
|
|
8
17
|
def build_encoders
|
9
|
-
|
10
|
-
Request::
|
11
|
-
Request::
|
12
|
-
|
13
|
-
Request::RunWithMetadataMessage::SIGNATURE => Encode::RunWithMetadataMessageEncoder.new,
|
14
|
-
Request::DiscardAllMessage::SIGNATURE => Encode::DiscardAllMessageEncoder.new,
|
15
|
-
Request::PullAllMessage::SIGNATURE => Encode::PullAllMessageEncoder.new,
|
16
|
-
|
17
|
-
Request::BeginMessage::SIGNATURE => Encode::BeginMessageEncoder.new,
|
18
|
-
Request::CommitMessage::SIGNATURE => Encode::CommitMessageEncoder.new,
|
19
|
-
Request::RollbackMessage::SIGNATURE => Encode::RollbackMessageEncoder.new,
|
20
|
-
Request::ResetMessage::SIGNATURE => Encode::ResetMessageEncoder.new,
|
21
|
-
}
|
18
|
+
COMMON_ENCODERS.merge(
|
19
|
+
Request::DiscardAllMessage::SIGNATURE => Encode::DiscardAllMessageEncoder,
|
20
|
+
Request::PullAllMessage::SIGNATURE => Encode::PullAllMessageEncoder,
|
21
|
+
)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -2,24 +2,13 @@ module Neo4j::Driver
|
|
2
2
|
module Internal
|
3
3
|
module Messaging
|
4
4
|
module V4
|
5
|
-
class MessageWriterV4 <
|
5
|
+
class MessageWriterV4 < V3::MessageWriterV3
|
6
6
|
private
|
7
7
|
|
8
8
|
def build_encoders
|
9
|
-
|
10
|
-
Request::
|
11
|
-
Request::
|
12
|
-
Request::RunWithMetadataMessage::SIGNATURE => Encode::RunWithMetadataMessageEncoder.new,
|
13
|
-
|
14
|
-
Request::DiscardAllMessage::SIGNATURE => Encode::DiscardAllMessageEncoder.new, # new
|
15
|
-
Request::PullMessage::SIGNATURE => Encode::PullMessageEncoder.new, # new
|
16
|
-
|
17
|
-
Request::BeginMessage::SIGNATURE => Encode::BeginMessageEncoder.new,
|
18
|
-
Request::CommitMessage::SIGNATURE => Encode::CommitMessageEncoder.new,
|
19
|
-
Request::RollbackMessage::SIGNATURE => Encode::RollbackMessageEncoder.new,
|
20
|
-
|
21
|
-
Request::ResetMessage::SIGNATURE => Encode::ResetMessageEncoder.new,
|
22
|
-
}
|
9
|
+
COMMON_ENCODERS.merge(
|
10
|
+
Request::DiscardMessage::SIGNATURE => Encode::DiscardMessageEncoder,
|
11
|
+
Request::PullMessage::SIGNATURE => Encode::PullMessageEncoder)
|
23
12
|
end
|
24
13
|
end
|
25
14
|
end
|
@@ -7,25 +7,11 @@ module Neo4j::Driver
|
|
7
7
|
# This version is able to encode all the versions existing on v4.2, but it encodes
|
8
8
|
|
9
9
|
# new messages such as ROUTE
|
10
|
-
class MessageWriterV43 <
|
10
|
+
class MessageWriterV43 < V4::MessageWriterV4
|
11
11
|
private
|
12
12
|
|
13
13
|
def build_encoders
|
14
|
-
|
15
|
-
Request::HelloMessage::SIGNATURE => Encode::HelloMessageEncoder.new,
|
16
|
-
Request::GoodbyeMessage::SIGNATURE => Encode::GoodbyeMessageEncoder.new,
|
17
|
-
Request::RunWithMetadataMessage::SIGNATURE => Encode::RunWithMetadataMessageEncoder.new,
|
18
|
-
Request::RouteMessage::SIGNATURE => Encode::RouteMessageEncoder.new, # new
|
19
|
-
|
20
|
-
Request::DiscardMessage::SIGNATURE => Encode::DiscardMessageEncoder.new,
|
21
|
-
Request::PullMessage::SIGNATURE => Encode::PullMessageEncoder.new,
|
22
|
-
|
23
|
-
Request::BeginMessage::SIGNATURE => Encode::BeginMessageEncoder.new,
|
24
|
-
Request::CommitMessage::SIGNATURE => Encode::CommitMessageEncoder.new,
|
25
|
-
Request::RollbackMessage::SIGNATURE => Encode::RollbackMessageEncoder.new,
|
26
|
-
|
27
|
-
Request::ResetMessage::SIGNATURE => Encode::ResetMessageEncoder.new,
|
28
|
-
}
|
14
|
+
super.merge(Request::RouteMessage::SIGNATURE => Encode::RouteMessageEncoder)
|
29
15
|
end
|
30
16
|
end
|
31
17
|
end
|
@@ -2,22 +2,11 @@ module Neo4j::Driver
|
|
2
2
|
module Internal
|
3
3
|
module Messaging
|
4
4
|
module V44
|
5
|
-
class MessageWriterV44 <
|
5
|
+
class MessageWriterV44 < V4::MessageWriterV4
|
6
6
|
private
|
7
7
|
|
8
8
|
def build_encoders
|
9
|
-
|
10
|
-
Request::HelloMessage::SIGNATURE => Encode::HelloMessageEncoder.new,
|
11
|
-
Request::GoodbyeMessage::SIGNATURE => Encode::GoodbyeMessageEncoder.new,
|
12
|
-
Request::RunWithMetadataMessage::SIGNATURE => Encode::RunWithMetadataMessageEncoder.new,
|
13
|
-
Request::RouteMessage::SIGNATURE => Encode::RouteV44MessageEncoder.new,
|
14
|
-
Request::DiscardMessage::SIGNATURE => Encode::DiscardMessageEncoder.new,
|
15
|
-
Request::PullMessage::SIGNATURE => Encode::PullMessageEncoder.new,
|
16
|
-
Request::BeginMessage::SIGNATURE => Encode::BeginMessageEncoder.new,
|
17
|
-
Request::CommitMessage::SIGNATURE => Encode::CommitMessageEncoder.new,
|
18
|
-
Request::RollbackMessage::SIGNATURE => Encode::RollbackMessageEncoder.new,
|
19
|
-
Request::ResetMessage::SIGNATURE => Encode::ResetMessageEncoder.new,
|
20
|
-
}
|
9
|
+
super.merge(Request::RouteMessage::SIGNATURE => Encode::RouteV44MessageEncoder)
|
21
10
|
end
|
22
11
|
end
|
23
12
|
end
|
@@ -143,7 +143,7 @@ module Neo4j::Driver
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def add_suppressed(error, suppressed_errors)
|
146
|
-
suppressed_errors&.reject(&error.method(:equal?))&.each(&error.method(:add_suppressed))
|
146
|
+
suppressed_errors&.reject(&error.method(:equal?))&.each(&error.method(:add_suppressed)) if error.is_a? Exceptions::Neo4jException
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
@@ -2,8 +2,6 @@ module Neo4j::Driver
|
|
2
2
|
module Internal
|
3
3
|
module Util
|
4
4
|
class MetadataExtractor
|
5
|
-
ABSENT_QUERY_ID = -1
|
6
|
-
|
7
5
|
def initialize(result_available_after_metadata_key, result_consumed_after_metadata_key)
|
8
6
|
@result_available_after_metadata_key = result_available_after_metadata_key
|
9
7
|
@result_consumed_after_metadata_key = result_consumed_after_metadata_key
|
@@ -14,7 +12,7 @@ module Neo4j::Driver
|
|
14
12
|
end
|
15
13
|
|
16
14
|
def extract_query_id(metadata)
|
17
|
-
metadata[:qid]
|
15
|
+
metadata[:qid]
|
18
16
|
end
|
19
17
|
|
20
18
|
def extract_result_available_after(metadata)
|
data/ruby/neo4j/driver.rb
CHANGED
@@ -5,9 +5,8 @@ require 'active_support/core_ext/hash/keys'
|
|
5
5
|
require 'active_support/logger'
|
6
6
|
require 'async/io'
|
7
7
|
require 'async/io/stream'
|
8
|
-
require 'async/pool'
|
9
|
-
require 'async/pool/resource'
|
10
8
|
require 'async/queue'
|
9
|
+
require 'connection_pool'
|
11
10
|
require 'bigdecimal'
|
12
11
|
require 'date'
|
13
12
|
require 'loader'
|
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.
|
4
|
+
version: 4.4.0.beta.1
|
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-
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: connection_pool
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -294,6 +294,7 @@ files:
|
|
294
294
|
- ruby/neo4j/driver/internal/async/pool/netty_channel_pool.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
|
+
- ruby/neo4j/driver/internal/async/pool/timed_stack.rb
|
297
298
|
- ruby/neo4j/driver/internal/async/result_cursors_holder.rb
|
298
299
|
- ruby/neo4j/driver/internal/async/unmanaged_transaction.rb
|
299
300
|
- ruby/neo4j/driver/internal/bookmark_holder.rb
|
@@ -473,7 +474,6 @@ files:
|
|
473
474
|
- ruby/neo4j/driver/net/server_address.rb
|
474
475
|
- ruby/neo4j/driver/query.rb
|
475
476
|
- ruby/neo4j/driver/records.rb
|
476
|
-
- ruby/neo4j/driver/session_config.rb
|
477
477
|
- ruby/neo4j/driver/transaction_config.rb
|
478
478
|
- ruby/neo4j/driver/values.rb
|
479
479
|
- ruby/neo4j/driver/version.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Neo4j
|
2
|
-
module Driver
|
3
|
-
# The session configurations used to configure a session.
|
4
|
-
class SessionConfig < Hash
|
5
|
-
attr_reader :bookmarks, :default_access_mode, :database, :fetch_size, :impersonated_user
|
6
|
-
def initialize(**config)
|
7
|
-
@bookmarks = config.bookmarks
|
8
|
-
@default_access_mode = config.default_access_mode
|
9
|
-
@database = config.database
|
10
|
-
@fetch_size = config.fetch_size
|
11
|
-
@impersonated_user = config.impersonated_user
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|