Class: Xfers::Etcd::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/xfers/etcd/pool.rb

Overview

Etcd v3 client connection pool

Instance Method Summary collapse

Constructor Details

#initialize(pool_size: 10, pool_timeout: 10, **options) ⇒ Pool

Returns a new instance of Pool.



7
8
9
10
11
# File 'lib/xfers/etcd/pool.rb', line 7

def initialize(pool_size: 10, pool_timeout: 10, **options)
  @pool = ConnectionPool.new(pool_size: pool_size, pool_timeout: pool_timeout) do
    Client.new(**options)
  end
end

Instance Method Details

#pool_available?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/xfers/etcd/pool.rb', line 25

def pool_available?
  @pool.available
end

#pool_shutdown(&block) ⇒ Object



17
18
19
# File 'lib/xfers/etcd/pool.rb', line 17

def pool_shutdown(&block)
  @pool.shutdown(&block)
end

#pool_sizeObject



21
22
23
# File 'lib/xfers/etcd/pool.rb', line 21

def pool_size
  @pool.size
end

#transaction(timeout: nil, &block) ⇒ Object



53
54
55
56
57
# File 'lib/xfers/etcd/pool.rb', line 53

def transaction(timeout: nil, &block)
  @pool.with do |client|
    client.transaction(timeout: timeout, &block)
  end
end

#watch(key, timeout: nil, &block) ⇒ Object



29
30
31
32
33
# File 'lib/xfers/etcd/pool.rb', line 29

def watch(key, timeout: nil, &block)
  @pool.with do |client|
    client.watch(key, timeout: timeout, &block)
  end
end

#watch_forever(key, &block) ⇒ Object



35
36
37
38
39
# File 'lib/xfers/etcd/pool.rb', line 35

def watch_forever(key, &block)
  @pool.with do |client|
    client.watch_forever(key, &block)
  end
end

#watch_prefix(key_prefix, timeout: nil, &block) ⇒ Object



41
42
43
44
45
# File 'lib/xfers/etcd/pool.rb', line 41

def watch_prefix(key_prefix, timeout: nil, &block)
  @pool.with do |client|
    client.watch(key_prefix, timeout: timeout, &block)
  end
end

#watch_prefix_forever(key_prefix, &block) ⇒ Object



47
48
49
50
51
# File 'lib/xfers/etcd/pool.rb', line 47

def watch_prefix_forever(key_prefix, &block)
  @pool.with do |client|
    client.watch_forever(key_prefix, &block)
  end
end

#with(timeout: nil, &block) ⇒ Object



13
14
15
# File 'lib/xfers/etcd/pool.rb', line 13

def with(timeout: nil, &block)
  @pool.with(timeout: timeout, &block)
end