Module: ZK::Event
- Includes:
- Zookeeper::Constants
- Defined in:
- lib/zk/event.rb
Overview
Provides most of the functionality ZK uses around events. Base class is actually Zookeeper::Callbacks::WatcherCallback, but this module is mixed in and provides a lot of useful syntactic sugar.
Instance Method Summary collapse
-
#associating? ⇒ Boolean
(also: #state_associating?)
Is this event notifying us we're in the associating state?.
-
#auth_failed? ⇒ Boolean
(also: #state_auth_failed?)
Is this event notifying us we're in the auth_failed state?.
-
#client_invalid? ⇒ Boolean
according to the programmer's guide.
-
#connected? ⇒ Boolean
(also: #state_connected?)
Is this event notifying us we're in the connected state?.
-
#connecting? ⇒ Boolean
(also: #state_connecting?)
Is this event notifying us we're in the connecting state?.
-
#event_name ⇒ Object
return this event's type name as a string "ZOO_*_EVENT", used for debugging.
-
#expired_session? ⇒ Boolean
(also: #state_expired_session?)
Is this event notifying us we're in the expired_session state?.
-
#node_changed? ⇒ Boolean
(also: #changed?)
Has a node changed?.
-
#node_child? ⇒ Boolean
(also: #child?)
Has a node's list of children changed?.
-
#node_created? ⇒ Boolean
(also: #created?)
Has a node been created?.
-
#node_deleted? ⇒ Boolean
(also: #deleted?)
Has a node been deleted?.
-
#node_event? ⇒ Boolean
(also: #node?)
has this watcher been called because of a change to a zookeeper node?
node_event?
andsession_event?
are mutually exclusive. -
#node_notwatching? ⇒ Boolean
(also: #node_not_watching?)
I have never seen this event delivered.
-
#node_session? ⇒ Boolean
deprecated
Deprecated.
This was an artifact of the way these methods were created originally, will be removed because it's kinda dumb. use #session_event?
-
#path ⇒ String?
The path this event is in reference to.
-
#session_event? ⇒ Boolean
(also: #state_event?, #session?)
has this watcher been called because of a change in connection state?.
-
#state ⇒ Fixnum
The numeric constant (one of
ZOO_*_STATE
) that ZooKeeper sets to indicate the session state this event is notifying us of. -
#state_name ⇒ Object
return this event's state name as a string "ZOO_*_STATE", used for debugging.
-
#type ⇒ Fixnum
The numeric constant (one of
ZOO_*_EVENT
) that ZooKeeper sets to indicate the type of event this is.
Instance Method Details
#associating? ⇒ Boolean Also known as: state_associating?
Is this event notifying us we're in the associating state?
73 74 75 |
# File 'lib/zk/event.rb', line 73 def associating? @state == ZOO_ASSOCIATING_STATE end |
#auth_failed? ⇒ Boolean Also known as: state_auth_failed?
Is this event notifying us we're in the auth_failed state?
85 86 87 |
# File 'lib/zk/event.rb', line 85 def auth_failed? @state == ZOO_AUTH_FAILED_STATE end |
#client_invalid? ⇒ Boolean
according to the programmer's guide
once a ZooKeeper object is closed or receives a fatal event (SESSION_EXPIRED and AUTH_FAILED), the ZooKeeper object becomes invalid.
this will return true for either of those cases
172 173 174 |
# File 'lib/zk/event.rb', line 172 def client_invalid? (@state == ZOO_EXPIRED_SESSION_STATE) || (@state == ZOO_AUTH_FAILED_STATE) end |
#connected? ⇒ Boolean Also known as: state_connected?
Is this event notifying us we're in the connected state?
79 80 81 |
# File 'lib/zk/event.rb', line 79 def connected? @state == ZOO_CONNECTED_STATE end |
#connecting? ⇒ Boolean Also known as: state_connecting?
Is this event notifying us we're in the connecting state?
67 68 69 |
# File 'lib/zk/event.rb', line 67 def connecting? @state == ZOO_CONNECTING_STATE end |
#event_name ⇒ Object
return this event's type name as a string "ZOO_*_EVENT", used for debugging
140 141 142 |
# File 'lib/zk/event.rb', line 140 def event_name (name = EVENT_TYPE_NAMES[@type]) ? "ZOO_#{name.to_s.upcase}_EVENT" : '' end |
#expired_session? ⇒ Boolean Also known as: state_expired_session?
Is this event notifying us we're in the expired_session state?
91 92 93 |
# File 'lib/zk/event.rb', line 91 def expired_session? @state == ZOO_EXPIRED_SESSION_STATE end |
#node_changed? ⇒ Boolean Also known as: changed?
Has a node changed?
114 115 116 |
# File 'lib/zk/event.rb', line 114 def node_changed? @type == ZOO_CHANGED_EVENT end |
#node_child? ⇒ Boolean Also known as: child?
Has a node's list of children changed?
120 121 122 |
# File 'lib/zk/event.rb', line 120 def node_child? @type == ZOO_CHILD_EVENT end |
#node_created? ⇒ Boolean Also known as: created?
Has a node been created?
102 103 104 |
# File 'lib/zk/event.rb', line 102 def node_created? @type == ZOO_CREATED_EVENT end |
#node_deleted? ⇒ Boolean Also known as: deleted?
Has a node been deleted?
108 109 110 |
# File 'lib/zk/event.rb', line 108 def node_deleted? @type == ZOO_DELETED_EVENT end |
#node_event? ⇒ Boolean Also known as: node?
has this watcher been called because of a change to a zookeeper node?
node_event?
and session_event?
are mutually exclusive.
159 160 161 |
# File 'lib/zk/event.rb', line 159 def node_event? path and not path.empty? end |
#node_notwatching? ⇒ Boolean Also known as: node_not_watching?
I have never seen this event delivered. here for completeness.
134 135 136 |
# File 'lib/zk/event.rb', line 134 def node_notwatching? @type == ZOO_NOTWATCHING_EVENT end |
#node_session? ⇒ Boolean
This was an artifact of the way these methods were created originally, will be removed because it's kinda dumb. use #session_event?
Is this a session-related event?
129 130 131 |
# File 'lib/zk/event.rb', line 129 def node_session? @type == ZOO_SESSION_EVENT end |
#path ⇒ String?
The path this event is in reference to.
61 62 63 64 |
# File 'lib/zk/event.rb', line 61 def path # no-op, the functionality is provided by the class this is mixed into. # here only for documentation purposes end |
#session_event? ⇒ Boolean Also known as: state_event?, session?
has this watcher been called because of a change in connection state?
151 152 153 |
# File 'lib/zk/event.rb', line 151 def session_event? @type == ZOO_SESSION_EVENT end |
#state ⇒ Fixnum
The numeric constant (one of ZOO_*_STATE
) that ZooKeeper sets to
indicate the session state this event is notifying us of. Users are
encouraged to use the '?' methods below, instead of this value.
52 53 54 55 |
# File 'lib/zk/event.rb', line 52 def state # no-op, the functionality is provided by the class this is mixed into. # here only for documentation purposes end |
#state_name ⇒ Object
return this event's state name as a string "ZOO_*_STATE", used for debugging
97 98 99 |
# File 'lib/zk/event.rb', line 97 def state_name (name = STATE_NAMES[@state]) ? "ZOO_#{name.to_s.upcase}_STATE" : '' end |
#type ⇒ Fixnum
The numeric constant (one of ZOO_*_EVENT
) that ZooKeeper sets to
indicate the type of event this is. Users are advised to use the '?'
methods below instead of using this value.
42 43 44 45 |
# File 'lib/zk/event.rb', line 42 def type # no-op, the functionality is provided by the class this is mixed into. # here only for documentation purposes end |