class Roma::Client::ClientPool
RomaClient
Pool class
This class is implemented as Singleton. You can get RomaClient
as follows.
client = Roma::Client::ClientPool.instance.client
You can change pool size of RomaClient
to call “max_pool_size=” method . Default max pool size is 1.
Attributes
default_hash_name[RW]
max_pool_size[RW]
servers[RW]
start_sync_routing_proc[RW]
Public Class Methods
client_pools()
click to toggle source
get all pool
# File lib/roma/client/client_pool.rb 30 def self.client_pools 31 @@client_pools ||= {} 32 end
instance(type = :default)
click to toggle source
get ClientPool
instance
- type
-
identifier for client groups.
# File lib/roma/client/client_pool.rb 24 def self.instance(type = :default) 25 client_pools[type] ||= new 26 client_pools[type] 27 end
new()
click to toggle source
# File lib/roma/client/client_pool.rb 110 def initialize 111 @max_pool_size = 1 112 @clients = [] 113 @plugin_modules = nil 114 self.servers = nil 115 self.default_hash_name = 'roma' 116 self.start_sync_routing_proc = true 117 end
release_all()
click to toggle source
release all pool
# File lib/roma/client/client_pool.rb 35 def self.release_all 36 client_pools.each do |k,v| 37 v.release 38 end 39 end
Public Instance Methods
add_plugin_module(m)
click to toggle source
add plugin module
# File lib/roma/client/client_pool.rb 96 def add_plugin_module(m) 97 @plugin_modules ||= [] 98 @plugin_modules.push(m) 99 end
client() { |c| ... }
click to toggle source
get RomaClient
instance
- type
-
RomaClient
instance group. - return
-
RomaClient
instance
# File lib/roma/client/client_pool.rb 45 def client 46 c = nil 47 if @clients.empty? 48 c = Roma::Client::RomaClient.new(servers, 49 plugin_modules, 50 start_sync_routing_proc) 51 c.default_hash_name = default_hash_name 52 else 53 c = @clients.pop 54 end 55 56 if block_given? 57 begin 58 yield c 59 ensure 60 push_client(c) 61 end 62 else 63 return c 64 end 65 end
clients()
click to toggle source
get all clients
# File lib/roma/client/client_pool.rb 86 def clients 87 @clients 88 end
plugin_modules()
click to toggle source
get plugin_modules
# File lib/roma/client/client_pool.rb 91 def plugin_modules 92 @plugin_modules 93 end
plugin_modules=(modules)
click to toggle source
set plugin modules
You can set class Array.
# File lib/roma/client/client_pool.rb 104 def plugin_modules=(modules) 105 @plugin_modules = modules 106 end
pool_count()
click to toggle source
get pool count of clients
# File lib/roma/client/client_pool.rb 68 def pool_count 69 @clients.size 70 end
push_client(client)
click to toggle source
push RomaClient
instance
# File lib/roma/client/client_pool.rb 79 def push_client(client) 80 if @clients.size < max_pool_size 81 @clients.push(client) 82 end 83 end
release()
click to toggle source
release all pool clients
# File lib/roma/client/client_pool.rb 73 def release 74 @clients.clear 75 true 76 end