Class: ZookeeperEM::Client
- Inherits:
-
Zookeeper::Client
- Object
- Zookeeper::ZookeeperBase
- Zookeeper::Client
- ZookeeperEM::Client
- Defined in:
- lib/zookeeper/em_client.rb
Constant Summary
Constants inherited from Zookeeper::ZookeeperBase
Zookeeper::ZookeeperBase::KILL_TOKEN, Zookeeper::ZookeeperBase::ZKRB_GLOBAL_CB_REQ, Zookeeper::ZookeeperBase::ZOO_LOG_LEVEL_DEBUG, Zookeeper::ZookeeperBase::ZOO_LOG_LEVEL_ERROR, Zookeeper::ZookeeperBase::ZOO_LOG_LEVEL_INFO, Zookeeper::ZookeeperBase::ZOO_LOG_LEVEL_WARN
Constants included from Zookeeper::Exceptions
Zookeeper::Exceptions::ExpiredSession
Constants included from Zookeeper::Constants
Zookeeper::Constants::CONNECTED_EVENT_VALUES, Zookeeper::Constants::EVENT_TYPE_NAMES, Zookeeper::Constants::STATE_NAMES, Zookeeper::Constants::ZAPIERROR, Zookeeper::Constants::ZAUTHFAILED, Zookeeper::Constants::ZBADARGUMENTS, Zookeeper::Constants::ZBADVERSION, Zookeeper::Constants::ZCLOSING, Zookeeper::Constants::ZCONNECTIONLOSS, Zookeeper::Constants::ZDATAINCONSISTENCY, Zookeeper::Constants::ZINVALIDACL, Zookeeper::Constants::ZINVALIDCALLBACK, Zookeeper::Constants::ZINVALIDSTATE, Zookeeper::Constants::ZKRB_ASYNC_CONTN_ID, Zookeeper::Constants::ZKRB_GLOBAL_CB_REQ, Zookeeper::Constants::ZMARSHALLINGERROR, Zookeeper::Constants::ZNOAUTH, Zookeeper::Constants::ZNOCHILDRENFOREPHEMERALS, Zookeeper::Constants::ZNODEEXISTS, Zookeeper::Constants::ZNONODE, Zookeeper::Constants::ZNOTEMPTY, Zookeeper::Constants::ZNOTHING, Zookeeper::Constants::ZOK, Zookeeper::Constants::ZOO_ASSOCIATING_STATE, Zookeeper::Constants::ZOO_AUTH_FAILED_STATE, Zookeeper::Constants::ZOO_CHANGED_EVENT, Zookeeper::Constants::ZOO_CHILD_EVENT, Zookeeper::Constants::ZOO_CLOSED_STATE, Zookeeper::Constants::ZOO_CONNECTED_STATE, Zookeeper::Constants::ZOO_CONNECTING_STATE, Zookeeper::Constants::ZOO_CREATED_EVENT, Zookeeper::Constants::ZOO_DELETED_EVENT, Zookeeper::Constants::ZOO_EPHEMERAL, Zookeeper::Constants::ZOO_EXPIRED_SESSION_STATE, Zookeeper::Constants::ZOO_LOG_LEVEL_DEBUG, Zookeeper::Constants::ZOO_LOG_LEVEL_ERROR, Zookeeper::Constants::ZOO_LOG_LEVEL_INFO, Zookeeper::Constants::ZOO_LOG_LEVEL_WARN, Zookeeper::Constants::ZOO_NOTWATCHING_EVENT, Zookeeper::Constants::ZOO_SEQUENCE, Zookeeper::Constants::ZOO_SESSION_EVENT, Zookeeper::Constants::ZOPERATIONTIMEOUT, Zookeeper::Constants::ZRUNTIMEINCONSISTENCY, Zookeeper::Constants::ZSESSIONEXPIRED, Zookeeper::Constants::ZSESSIONMOVED, Zookeeper::Constants::ZSYSTEMERROR, Zookeeper::Constants::ZUNIMPLEMENTED
Constants included from Zookeeper::ACLs::Constants
Zookeeper::ACLs::Constants::ZOO_ANYONE_ID_UNSAFE, Zookeeper::ACLs::Constants::ZOO_AUTH_IDS, Zookeeper::ACLs::Constants::ZOO_CREATOR_ALL_ACL, Zookeeper::ACLs::Constants::ZOO_OPEN_ACL_UNSAFE, Zookeeper::ACLs::Constants::ZOO_PERM_ADMIN, Zookeeper::ACLs::Constants::ZOO_PERM_ALL, Zookeeper::ACLs::Constants::ZOO_PERM_CREATE, Zookeeper::ACLs::Constants::ZOO_PERM_DELETE, Zookeeper::ACLs::Constants::ZOO_PERM_READ, Zookeeper::ACLs::Constants::ZOO_PERM_WRITE, Zookeeper::ACLs::Constants::ZOO_READ_ACL_UNSAFE
Constants included from Zookeeper::Common
Zookeeper::Common::ZKRB_GLOBAL_CB_REQ
Instance Attribute Summary collapse
-
#em_connection ⇒ Object
readonly
the EM Connection instance we receive once we call EM.watch on our selectable_io.
Attributes inherited from Zookeeper::ZookeeperBase
Instance Method Summary collapse
- #close(&block) ⇒ Object
- #dispatch_next_callback(hash) ⇒ Object
-
#event_dispatch_thread? ⇒ Boolean
Because eventmachine is single-threaded, and events are dispatched on the reactor thread we just delegate this to EM.reactor_thread?.
-
#initialize(*a, &b) ⇒ Client
constructor
A new instance of Client.
-
#on_attached(&block) ⇒ Object
called after we’ve successfully registered our selectable_io to be managed by the EM reactor.
-
#on_close(&block) ⇒ Object
EM::DefaultDeferrable that will be called back when our em_connection has been detached and we’ve completed the close operation.
Methods inherited from Zookeeper::ZookeeperBase
#assert_open, #close!, #closed?, #create, #reopen, #session_id, #session_passwd, #set_debug_level, #set_default_global_watcher, #state, threadsafe_inquisitor
Methods included from Zookeeper::Logger
Methods included from Zookeeper::Exceptions
Methods included from Zookeeper::Constants
#event_by_value, #state_by_value
Methods included from Zookeeper::Forked
Constructor Details
#initialize(*a, &b) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 |
# File 'lib/zookeeper/em_client.rb', line 10 def initialize(*a, &b) @on_close = EM::DefaultDeferrable.new @on_attached = EM::DefaultDeferrable.new @em_connection = nil logger.debug { "ZookeeperEM::Client obj_id %x: init" % [object_id] } super(*a, &b) on_attached.succeed end |
Instance Attribute Details
#em_connection ⇒ Object (readonly)
the EM Connection instance we receive once we call EM.watch on our selectable_io
8 9 10 |
# File 'lib/zookeeper/em_client.rb', line 8 def em_connection @em_connection end |
Instance Method Details
#close(&block) ⇒ Object
42 43 44 45 46 |
# File 'lib/zookeeper/em_client.rb', line 42 def close(&block) on_close(&block) super() on_close.succeed end |
#dispatch_next_callback(hash) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/zookeeper/em_client.rb', line 33 def dispatch_next_callback(hash) EM.schedule do if running? and not closed? logger.debug { "#{self.class}##{__method__} dispatch_next_callback: #{hash.inspect}: reactor_thread? #{EM.reactor_thread?}, running? #{running?}, closed? #{closed?}" } super(hash) end end end |
#event_dispatch_thread? ⇒ Boolean
Because eventmachine is single-threaded, and events are dispatched on the reactor thread we just delegate this to EM.reactor_thread?
50 51 52 |
# File 'lib/zookeeper/em_client.rb', line 50 def event_dispatch_thread? EM.reactor_thread? end |
#on_attached(&block) ⇒ Object
called after we’ve successfully registered our selectable_io to be managed by the EM reactor
28 29 30 31 |
# File 'lib/zookeeper/em_client.rb', line 28 def on_attached(&block) @on_attached.callback(&block) if block @on_attached end |
#on_close(&block) ⇒ Object
EM::DefaultDeferrable that will be called back when our em_connection has been detached and we’ve completed the close operation
21 22 23 24 |
# File 'lib/zookeeper/em_client.rb', line 21 def on_close(&block) @on_close.callback(&block) if block @on_close end |