Class: Undertow::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/undertow/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



24
25
26
27
28
# File 'lib/undertow/configuration.rb', line 24

def initialize
  @max_batch      = 1_000
  @queue_name     = :undertow
  @drain_lock_key = 'undertow:drain:lock'
end

Instance Attribute Details

#drain_lock_keyObject

Redis key used for the distributed drain lock. The scheduler acquires this lock (SET NX) before enqueueing DrainJob; the job releases it immediately on start so new work arriving mid-drain gets its own job on the next tick. Set to nil to disable lock management entirely.



22
23
24
# File 'lib/undertow/configuration.rb', line 22

def drain_lock_key
  @drain_lock_key
end

#max_batchObject

Maximum number of IDs to pop from the buffer per drain per model.



13
14
15
# File 'lib/undertow/configuration.rb', line 13

def max_batch
  @max_batch
end

#queue_nameObject

ActiveJob queue to use for DrainJob.



16
17
18
# File 'lib/undertow/configuration.rb', line 16

def queue_name
  @queue_name
end

#redisObject

A Redis client or connection pool. Must respond to :sadd, :srem, :smembers, :spop, :scard, :del. Injected by the host application:

Undertow.configure { |c| c.redis = Redis.new(url: ENV['REDIS_URL']) }


10
11
12
# File 'lib/undertow/configuration.rb', line 10

def redis
  @redis
end

Instance Method Details

#redis!Object



30
31
32
# File 'lib/undertow/configuration.rb', line 30

def redis!
  redis or raise 'Undertow.configuration.redis is not set'
end