Class: Sensu::SocketHandler

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/sensu/socket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#on_errorObject

Returns the value of attribute on_error.



59
60
61
# File 'lib/sensu/socket.rb', line 59

def on_error
  @on_error
end

#on_successObject

Returns the value of attribute on_success.



59
60
61
# File 'lib/sensu/socket.rb', line 59

def on_success
  @on_success
end

Instance Method Details

#connection_completedObject



61
62
63
64
# File 'lib/sensu/socket.rb', line 61

def connection_completed
  @connected_at = Time.now.to_f
  @inactivity_timeout = comm_inactivity_timeout
end

#unbindObject



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/sensu/socket.rb', line 66

def unbind
  if @connected_at
    elapsed_time = Time.now.to_f - @connected_at
    if elapsed_time >= @inactivity_timeout
      @on_error.call('socket inactivity timeout')
    else
      @on_success.call('wrote to socket')
    end
  else
    @on_error.call('failed to connect to socket')
  end
end