forked from deliveroo/routemaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutemaster.rb
46 lines (39 loc) · 914 Bytes
/
routemaster.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Routemaster
def self.now
(Time.now.utc.to_f * 1e3).to_i
end
DEFAULTS = {
redis_pool_size: 1,
process_type: 'unknown',
}.freeze
def self.configure(**options)
@_config = DEFAULTS.merge(options)
counters.incr('process', type: config[:process_type], status: 'start')
self
end
def self.teardown
counters.incr('process', type: config[:process_type], status: 'stop').finalize
self
end
def self.config
@_config || DEFAULTS
end
def self.batch_queue
@_batch_queue ||= begin
require 'routemaster/models/queue'
Models::Queue.new(name: 'main')
end
end
def self.aux_queue
@_aux_queue ||= begin
require 'routemaster/models/queue'
Models::Queue.new(name: 'aux')
end
end
def self.counters
@_counters ||= begin
require 'routemaster/models/counters'
Models::Counters.instance
end
end
end