Sha256: daedfbe5d26785f81fdf8ee00e6b3b85975556131752c125682142fae3187db0

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

module ZK
  module Client
    # This is the default client that ZK will use. In the zk-eventmachine gem,
    # there is an Evented client.
    class Threaded < Base
      include StateMixin
      include Unixisms
      include Conveniences

      # Create a new client and connect to the zookeeper server. 
      #
      # +host+ should be a string of comma-separated host:port pairs. You can
      # also supply an optional "chroot" suffix that will act as an implicit 
      # prefix to all paths supplied.
      #
      # example:
      #    
      #   ZK::Client.new("zk01:2181,zk02:2181/chroot/path")
      #
      def initialize(host, opts={})
        @event_handler = EventHandler.new(self)
        yield self if block_given?
        @cnx = ::Zookeeper.new(host, DEFAULT_TIMEOUT, @event_handler.get_default_watcher_block)
        @threadpool = Threadpool.new
      end

      # closes the underlying connection and deregisters all callbacks
      def close!
        @threadpool.shutdown
        super
        nil
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
zk-0.8.9 lib/z_k/client/threaded.rb
zk-0.8.8 lib/z_k/client/threaded.rb
zk-0.8.7 lib/z_k/client/threaded.rb
zk-0.8.6 lib/z_k/client/threaded.rb
zk-0.8.5 lib/z_k/client/threaded.rb
zk-0.8.4 lib/z_k/client/threaded.rb
zk-0.8.3 lib/z_k/client/threaded.rb
zk-0.8.2 lib/z_k/client/threaded.rb