Module: Officer::Connection::LockStoreCallbacks

Included in:
Connection
Defined in:
lib/officer/connection.rb

Instance Method Summary collapse

Instance Method Details

#acquired(name) ⇒ Object



37
38
39
40
41
# File 'lib/officer/connection.rb', line 37

def acquired name
  @timers.delete(name).cancel if @timers[name]

  send_result 'acquired', :name => name
end

#already_acquired(name) ⇒ Object



43
44
45
# File 'lib/officer/connection.rb', line 43

def already_acquired name
  send_result 'already_acquired', :name => name
end

#connections(conns_hash) ⇒ Object



79
80
81
# File 'lib/officer/connection.rb', line 79

def connections conns_hash
  send_result 'connections', :value => conns_hash
end

#locks(locks_hash) ⇒ Object



75
76
77
# File 'lib/officer/connection.rb', line 75

def locks locks_hash
  send_result 'locks', :value => locks_hash
end

#my_locks(names) ⇒ Object



87
88
89
# File 'lib/officer/connection.rb', line 87

def my_locks names
  send_result 'my_locks', :value => names
end

#queue_maxed(name, options = {}) ⇒ Object



83
84
85
# File 'lib/officer/connection.rb', line 83

def queue_maxed name, options={}
  send_result 'queue_maxed', :name => name, :queue => options[:queue]
end

#queued(name, options = {}) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/officer/connection.rb', line 60

def queued name, options={}
  timeout = options[:timeout]

  return if timeout.nil? || @timers[name]

  @timers[name] = EM::Timer.new(timeout) do
    Officer::LockStore.instance.timeout name, self
  end
end

#release_failed(name) ⇒ Object



51
52
53
# File 'lib/officer/connection.rb', line 51

def release_failed name
  send_result 'release_failed', :name => name
end

#released(name) ⇒ Object



47
48
49
# File 'lib/officer/connection.rb', line 47

def released name
  send_result 'released', :name => name
end

#reset_succeededObject



55
56
57
58
# File 'lib/officer/connection.rb', line 55

def reset_succeeded
  @timers.values.each {|timer| timer.cancel}
  send_result 'reset_succeeded'
end

#timed_out(name, options = {}) ⇒ Object



70
71
72
73
# File 'lib/officer/connection.rb', line 70

def timed_out name, options={}
  @timers.delete name
  send_result 'timed_out', :name => name, :queue => options[:queue]
end