neo4j-ruby-driver 4.4.0.alpha.9 → 4.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41dc794832386239a05ddcc44bb1937da85f8d1b3d0be4977ab3b53157ab5ac0
4
- data.tar.gz: e085f6bfce9255985ead9e0aab6bd70a8495f9b62bbfa16fbe38efaac1508032
3
+ metadata.gz: c795045f581183398e15ba5c44c1f89b10ea234a9a6dc1e46fecd8c02b857bb3
4
+ data.tar.gz: 1859daea7265d9409d001e748048ab97837fe26895d80fe4e24773b1b51ed49d
5
5
  SHA512:
6
- metadata.gz: d3eeaeaeb2a4f8d19ffacdec93f2fb64ff5c8a65ab27bf6593d4ae3ce2c08e092b97662bd6ab58f4cc59a5bb4d2215e1c8fe80c916c05eda9e9b9454b72411a5
7
- data.tar.gz: 0a86332ba42e153c1f21964fbca5a0cdba75bf5b3cea574ce40db4a1a54f090dd43d1b1f6096acb51e04ac7d6cdddaf03a3f84dad6fb4582de911d11f22824b5
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 < ::Async::Pool::Resource
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
@@ -2,14 +2,13 @@ module Neo4j::Driver
2
2
  module Internal
3
3
  module Async
4
4
  module Pool
5
- class Channel < ::Async::Pool::Resource
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?(::Async::TimeoutError)
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.wrap(limit: @settings.max_connection_pool_size, acquisition_timeout: @settings.connection_acquisition_timeout) { Channel.new(address, @connector, @log) }
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 < ::Async::Pool::Controller
6
- def initialize(constructor, limit: nil, concurrency: nil, acquisition_timeout: nil)
7
- super(constructor, limit: limit, concurrency: concurrency)
8
- @acquisition_timeout = acquisition_timeout
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 wait_for_resource
12
- case @acquisition_timeout
13
- when nil
14
- super
15
- when 0
16
- available_resource or raise ::Async::TimeoutError
17
- else
18
- ::Async::Task.current.with_timeout(@acquisition_timeout) { super }
19
- end
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
@@ -0,0 +1,15 @@
1
+ module Neo4j::Driver
2
+ module Internal
3
+ module Async
4
+ module Pool
5
+ class TimedStack < ConnectionPool::TimedStack
6
+ def any_resource_busy?
7
+ @mutex.synchronize do
8
+ @created > @que.length
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Neo4j
4
4
  module Driver
5
- VERSION = '4.4.0.alpha.9'
5
+ VERSION = '4.4.0.beta.1'
6
6
  end
7
7
  end
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.alpha.9
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-09-24 00:00:00.000000000 Z
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: async-pool
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