Class: Reqless::Throttle
- Inherits:
-
Object
- Object
- Reqless::Throttle
- Defined in:
- lib/reqless/throttle.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #delete ⇒ Object
- #expiration=(expire_time_in_seconds) ⇒ Object
- #id ⇒ Object
-
#initialize(name, client) ⇒ Throttle
constructor
A new instance of Throttle.
- #locks ⇒ Object
- #maximum ⇒ Object
- #maximum=(max) ⇒ Object
- #pending ⇒ Object
- #ttl ⇒ Object
Constructor Details
#initialize(name, client) ⇒ Throttle
Returns a new instance of Throttle.
10 11 12 13 |
# File 'lib/reqless/throttle.rb', line 10 def initialize(name, client) @name = name @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/reqless/throttle.rb', line 8 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/reqless/throttle.rb', line 8 def name @name end |
Instance Method Details
#delete ⇒ Object
15 16 17 |
# File 'lib/reqless/throttle.rb', line 15 def delete @client.call('throttle.delete', @name) end |
#expiration=(expire_time_in_seconds) ⇒ Object
19 20 21 |
# File 'lib/reqless/throttle.rb', line 19 def expiration=(expire_time_in_seconds) update(nil, Integer(expire_time_in_seconds)) end |
#id ⇒ Object
23 24 25 |
# File 'lib/reqless/throttle.rb', line 23 def id @name end |
#locks ⇒ Object
27 28 29 |
# File 'lib/reqless/throttle.rb', line 27 def locks JSON.parse(@client.call('throttle.locks', @name)) end |
#maximum ⇒ Object
31 32 33 |
# File 'lib/reqless/throttle.rb', line 31 def maximum throttle_attrs['maximum'].to_i end |
#maximum=(max) ⇒ Object
35 36 37 |
# File 'lib/reqless/throttle.rb', line 35 def maximum=(max) update(max) end |
#pending ⇒ Object
39 40 41 |
# File 'lib/reqless/throttle.rb', line 39 def pending JSON.parse(@client.call('throttle.pending', @name)) end |
#ttl ⇒ Object
43 44 45 |
# File 'lib/reqless/throttle.rb', line 43 def ttl throttle_attrs['ttl'].to_i end |