Class: Grumlin::Client::PoolResource
- Inherits:
-
Async::Pool::Resource
- Object
- Async::Pool::Resource
- Grumlin::Client::PoolResource
- Defined in:
- lib/grumlin/client.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(url, client_factory:, concurrency: 1, parent: Async::Task.current) ⇒ PoolResource
constructor
A new instance of PoolResource.
- #reusable? ⇒ Boolean
- #viable? ⇒ Boolean
- #write(query) ⇒ Object
Constructor Details
#initialize(url, client_factory:, concurrency: 1, parent: Async::Task.current) ⇒ PoolResource
Returns a new instance of PoolResource.
12 13 14 15 16 |
# File 'lib/grumlin/client.rb', line 12 def initialize(url, client_factory:, concurrency: 1, parent: Async::Task.current) super(concurrency) @client = client_factory.call(url, parent).tap(&:connect) @parent = parent end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/grumlin/client.rb', line 5 def client @client end |
Class Method Details
Instance Method Details
#close ⇒ Object
22 23 24 |
# File 'lib/grumlin/client.rb', line 22 def close @client.close end |
#closed? ⇒ Boolean
18 19 20 |
# File 'lib/grumlin/client.rb', line 18 def closed? !@client.connected? end |
#reusable? ⇒ Boolean
36 37 38 |
# File 'lib/grumlin/client.rb', line 36 def reusable? !closed? end |
#viable? ⇒ Boolean
32 33 34 |
# File 'lib/grumlin/client.rb', line 32 def viable? !closed? end |
#write(query) ⇒ Object
26 27 28 29 30 |
# File 'lib/grumlin/client.rb', line 26 def write(query) @client.write(query) ensure @count += 1 end |