Class: ZK::Pool::Simple

Inherits:
Bounded show all
Defined in:
lib/zk/pool.rb

Overview

create a connection pool useful for multithreaded applications

Will spin up number_of_connections at creation time and remain fixed at that number for the life of the pool.

Examples:


pool = ZK::Pool::Simple.new("localhost:2181", :timeout => 10)
pool.checkout do |zk|
  zk.create("/mynew_path")
end

Constant Summary

Constants inherited from Bounded

Bounded::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Base

#connections

Instance Method Summary collapse

Methods inherited from Bounded

#available_size, #checkin, #checkout, #count_waiters, #size

Methods inherited from Base

#close_all!, #closed?, #closing?, #forced?, #locker, #method_missing, #open?, #pool_state, #size, #with_connection, #with_lock

Methods included from Logger

#logger, wrapped_logger, wrapped_logger=

Constructor Details

#initialize(host, number_of_connections = 10, opts = {}) ⇒ ZK::ClientPool

initialize a connection pool using the same optons as ZK.new

Parameters:

  • host (String)

    the same arguments as ZK.new

  • number_of_connections (Integer) (defaults to: 10)

    the number of connections to put in the pool

  • opts (Hash) (defaults to: {})

    Options to pass on to each connection



325
326
327
328
329
330
# File 'lib/zk/pool.rb', line 325

def initialize(host, number_of_connections=10, opts = {})
  opts = opts.dup
  opts[:max_clients] = opts[:min_clients] = number_of_connections.to_i

  super(host, opts)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ZK::Pool::Base