Class: Raven::ClientState

Inherits:
Object
  • Object
show all
Defined in:
lib/raven/client.rb

Instance Method Summary collapse

Constructor Details

#initializeClientState

Returns a new instance of ClientState


109
110
111
# File 'lib/raven/client.rb', line 109

def initialize
  reset
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)

140
141
142
# File 'lib/raven/client.rb', line 140

def failed?
  @status == :error
end

#failure(retry_after = nil) ⇒ Object


122
123
124
125
126
127
# File 'lib/raven/client.rb', line 122

def failure(retry_after = nil)
  @status = :error
  @retry_number += 1
  @last_check = Time.now
  @retry_after = retry_after
end

#resetObject


133
134
135
136
137
138
# File 'lib/raven/client.rb', line 133

def reset
  @status = :online
  @retry_number = 0
  @last_check = nil
  @retry_after = nil
end

#should_try?Boolean

Returns:

  • (Boolean)

113
114
115
116
117
118
119
120
# File 'lib/raven/client.rb', line 113

def should_try?
  return true if @status == :online

  interval = @retry_after || [@retry_number, 6].min**2
  return true if Time.now - @last_check >= interval

  false
end

#successObject


129
130
131
# File 'lib/raven/client.rb', line 129

def success
  reset
end