Class: Reqless::Throttle

Inherits:
Object
  • Object
show all
Defined in:
lib/reqless/throttle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/reqless/throttle.rb', line 8

def client
  @client
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/reqless/throttle.rb', line 8

def name
  @name
end

Instance Method Details

#deleteObject



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

#idObject



23
24
25
# File 'lib/reqless/throttle.rb', line 23

def id
  @name
end

#locksObject



27
28
29
# File 'lib/reqless/throttle.rb', line 27

def locks
  JSON.parse(@client.call('throttle.locks', @name))
end

#maximumObject



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

#pendingObject



39
40
41
# File 'lib/reqless/throttle.rb', line 39

def pending
  JSON.parse(@client.call('throttle.pending', @name))
end

#ttlObject



43
44
45
# File 'lib/reqless/throttle.rb', line 43

def ttl
  throttle_attrs['ttl'].to_i
end