Module: ZK::ZKEventMachine::Callback

Defined in:
lib/z_k/z_k_event_machine/callback.rb

Overview

some improvements (one hopes) around the zookeeper gem’s somewhat (ahem) minimal Callback class

Defined Under Namespace

Classes: ACLCallback, Base, ChildrenCallback, DataCallback, ExistsCallback, SetCallback, StatCallback, StringCallback, VoidCallback

Class Method Summary collapse

Class Method Details

.new_acl_cb(njs_block) ⇒ Object Also known as: new_get_acl_cb



256
257
258
259
260
# File 'lib/z_k/z_k_event_machine/callback.rb', line 256

def new_acl_cb(njs_block)
  ACLCallback.new(njs_block).tap do |cb|
    cb.check_async_rc(yield(cb))
  end
end

.new_children_cb(njs_block) ⇒ Object



250
251
252
253
254
# File 'lib/z_k/z_k_event_machine/callback.rb', line 250

def new_children_cb(njs_block)
  ChildrenCallback.new(njs_block).tap do |cb|
    cb.check_async_rc(yield(cb))
  end
end

.new_data_cb(njs_block) ⇒ Object Also known as: new_get_cb



209
210
211
212
213
214
# File 'lib/z_k/z_k_event_machine/callback.rb', line 209

def new_data_cb(njs_block)
  DataCallback.new(njs_block).tap do |cb| # create the callback with the user-provided block
    cb.check_async_rc(yield(cb))          # yield the callback to the caller, check the return result 
                                          # of the async operation (not the async result)
  end                                     # return the callback
end

.new_exists_cb(njs_block) ⇒ Object



230
231
232
233
234
# File 'lib/z_k/z_k_event_machine/callback.rb', line 230

def new_exists_cb(njs_block)
  ExistsCallback.new(njs_block).tap do |cb|
    cb.check_async_rc(yield(cb))
  end
end

.new_set_cb(njs_block) ⇒ Object



236
237
238
239
240
# File 'lib/z_k/z_k_event_machine/callback.rb', line 236

def new_set_cb(njs_block)
  SetCallback.new(njs_block).tap do |cb|
    cb.check_async_rc(yield(cb))
  end
end

.new_stat_cb(njs_block) ⇒ Object



224
225
226
227
228
# File 'lib/z_k/z_k_event_machine/callback.rb', line 224

def new_stat_cb(njs_block)
  StatCallback.new(njs_block).tap do |cb|
    cb.check_async_rc(yield(cb))
  end
end

.new_string_cb(njs_block) ⇒ Object Also known as: new_create_cb

create alias so that this matches the client API name



217
218
219
220
221
# File 'lib/z_k/z_k_event_machine/callback.rb', line 217

def new_string_cb(njs_block)
  StringCallback.new(njs_block).tap do |cb|
    cb.check_async_rc(yield(cb))
  end
end

.new_void_cb(njs_block) ⇒ Object Also known as: new_delete_cb, new_set_acl_cb



242
243
244
245
246
# File 'lib/z_k/z_k_event_machine/callback.rb', line 242

def new_void_cb(njs_block)
  VoidCallback.new(njs_block).tap do |cb|
    cb.check_async_rc(yield(cb))
  end
end