Module: Sidekiq::LimitFetch::Global::Monitor
- Extended by:
- Monitor
- Includes:
- Redis
- Included in:
- Monitor
- Defined in:
- lib/sidekiq/limit_fetch/global/monitor.rb
Constant Summary
collapse
- HEARTBEAT_PREFIX =
'heartbeat:'
- PROCESS_SET =
'processes'
- HEARTBEAT_TTL =
18
- REFRESH_TIMEOUT =
10
Instance Method Summary
collapse
Methods included from Redis
#determine_namespace, #nonblocking_redis, #redis
Instance Method Details
#all_processes ⇒ Object
21
22
23
|
# File 'lib/sidekiq/limit_fetch/global/monitor.rb', line 21
def all_processes
redis {|it| it.smembers PROCESS_SET }
end
|
#old_processes ⇒ Object
25
26
27
28
29
|
# File 'lib/sidekiq/limit_fetch/global/monitor.rb', line 25
def old_processes
all_processes.reject do |process|
redis {|it| it.get heartbeat_key process }
end
end
|
#remove_old_processes! ⇒ Object
31
32
33
34
35
|
# File 'lib/sidekiq/limit_fetch/global/monitor.rb', line 31
def remove_old_processes!
redis do |it|
old_processes.each {|process| it.srem PROCESS_SET, process }
end
end
|
#start!(ttl = HEARTBEAT_TTL, timeout = REFRESH_TIMEOUT) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/sidekiq/limit_fetch/global/monitor.rb', line 11
def start!(ttl=HEARTBEAT_TTL, timeout=REFRESH_TIMEOUT)
Thread.new do
loop do
update_heartbeat ttl
invalidate_old_processes
sleep timeout
end
end
end
|