Class: Raven::ClientState
- Inherits:
-
Object
- Object
- Raven::ClientState
- Defined in:
- lib/raven/client.rb
Instance Method Summary collapse
- #failed? ⇒ Boolean
- #failure(retry_after = nil) ⇒ Object
-
#initialize ⇒ ClientState
constructor
A new instance of ClientState.
- #reset ⇒ Object
- #should_try? ⇒ Boolean
- #success ⇒ Object
Constructor Details
#initialize ⇒ ClientState
Returns a new instance of ClientState.
111 112 113 |
# File 'lib/raven/client.rb', line 111 def initialize reset end |
Instance Method Details
#failed? ⇒ Boolean
142 143 144 |
# File 'lib/raven/client.rb', line 142 def failed? @status == :error end |
#failure(retry_after = nil) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/raven/client.rb', line 124 def failure(retry_after = nil) @status = :error @retry_number += 1 @last_check = Time.now @retry_after = retry_after end |
#reset ⇒ Object
135 136 137 138 139 140 |
# File 'lib/raven/client.rb', line 135 def reset @status = :online @retry_number = 0 @last_check = nil @retry_after = nil end |
#should_try? ⇒ Boolean
115 116 117 118 119 120 121 122 |
# File 'lib/raven/client.rb', line 115 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 |
#success ⇒ Object
131 132 133 |
# File 'lib/raven/client.rb', line 131 def success reset end |