Module: Unbound::CallbacksMixin

Included in:
Query, Resolver
Defined in:
lib/unbound/callbacks_mixin.rb

Instance Method Summary collapse

Instance Method Details

#on_answer(*cbs, &cb_block) ⇒ Object

Adds a callback that will be called when we receive an answer to the query

Parameters:

  • cb (Proc)


30
31
32
# File 'lib/unbound/callbacks_mixin.rb', line 30

def on_answer(*cbs, &cb_block)
  @callbacks_answer.add_callback(*cbs, &cb_block)
end

#on_cancel(*cbs, &cb_block) ⇒ Object

Adds a callback that will be called if the query times out (dependant on the resolver)

Parameters:

  • cb (Proc)


43
44
45
# File 'lib/unbound/callbacks_mixin.rb', line 43

def on_cancel(*cbs, &cb_block)
  @callbacks_cancel.add_callback(*cbs, &cb_block)
end

#on_error(*cbs, &cb_block) ⇒ Object

Adds a callback that will be called when an error internal to unbound occurs

Parameters:

  • cb (Proc)


36
37
38
# File 'lib/unbound/callbacks_mixin.rb', line 36

def on_error(*cbs, &cb_block)
  @callbacks_error.add_callback(*cbs, &cb_block)
end

#on_finish(*cbs, &cb_block) ⇒ Object

Adds a callback will always be called when the query is finished whether answerfully, in error, or due to cancel.

Parameters:

  • cb (Proc)


50
51
52
# File 'lib/unbound/callbacks_mixin.rb', line 50

def on_finish(*cbs, &cb_block)
  @callbacks_finish.add_callback(*cbs, &cb_block)
end

#on_start(*cbs, &cb_block) ⇒ Object

Adds a callback that will be called just after the query is sent

Parameters:

  • cb (Proc)


24
25
26
# File 'lib/unbound/callbacks_mixin.rb', line 24

def on_start(*cbs, &cb_block)
  @callbacks_start.add_callback(*cbs, &cb_block)
end