Class: QPush::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/qpush/config.rb

Constant Summary collapse

DEFAULTS =
{
  redis_url: ENV['REDIS_URL'],
  database_url: ENV['DATABASE_URL'],
  redis_pool: 10,
  database_pool: 10,
  workers: 2,
  stats_namespace: 'qpush:v1:stats',
  queue_threads: 2,
  queue_namespace: 'qpush:v1:queue',
  perform_threads: 2,
  perform_namespace: 'qpush:v1:perform',
  delay_threads:1,
  delay_namespace: 'qpush:v1:delay',
  priorities: 5
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



40
41
42
# File 'lib/qpush/config.rb', line 40

def initialize
  DEFAULTS.each { |key, value| send("#{key}=", value) }
end

Instance Attribute Details

#database_adapterObject

Returns the value of attribute database_adapter.



35
36
37
# File 'lib/qpush/config.rb', line 35

def database_adapter
  @database_adapter
end

#database_poolObject

Returns the value of attribute database_pool.



35
36
37
# File 'lib/qpush/config.rb', line 35

def database_pool
  @database_pool
end

#database_urlObject

Returns the value of attribute database_url.



35
36
37
# File 'lib/qpush/config.rb', line 35

def database_url
  @database_url
end

#delay_namespaceObject

Returns the value of attribute delay_namespace.



35
36
37
# File 'lib/qpush/config.rb', line 35

def delay_namespace
  @delay_namespace
end

#delay_threadsObject

Returns the value of attribute delay_threads.



35
36
37
# File 'lib/qpush/config.rb', line 35

def delay_threads
  @delay_threads
end

#perform_namespaceObject

Returns the value of attribute perform_namespace.



35
36
37
# File 'lib/qpush/config.rb', line 35

def perform_namespace
  @perform_namespace
end

#perform_threadsObject

Returns the value of attribute perform_threads.



35
36
37
# File 'lib/qpush/config.rb', line 35

def perform_threads
  @perform_threads
end

#prioritiesObject

Returns the value of attribute priorities.



35
36
37
# File 'lib/qpush/config.rb', line 35

def priorities
  @priorities
end

#queue_namespaceObject

Returns the value of attribute queue_namespace.



35
36
37
# File 'lib/qpush/config.rb', line 35

def queue_namespace
  @queue_namespace
end

#queue_threadsObject

Returns the value of attribute queue_threads.



35
36
37
# File 'lib/qpush/config.rb', line 35

def queue_threads
  @queue_threads
end

#redis_poolObject

Returns the value of attribute redis_pool.



35
36
37
# File 'lib/qpush/config.rb', line 35

def redis_pool
  @redis_pool
end

#redis_urlObject

Returns the value of attribute redis_url.



35
36
37
# File 'lib/qpush/config.rb', line 35

def redis_url
  @redis_url
end

#stats_namespaceObject

Returns the value of attribute stats_namespace.



35
36
37
# File 'lib/qpush/config.rb', line 35

def stats_namespace
  @stats_namespace
end

#workersObject

Returns the value of attribute workers.



35
36
37
# File 'lib/qpush/config.rb', line 35

def workers
  @workers
end

Instance Method Details

#manager_optionsObject



52
53
54
55
56
57
# File 'lib/qpush/config.rb', line 52

def manager_options
  {
    workers: workers,
    options: worker_options
  }
end

#perform_listsObject



66
67
68
# File 'lib/qpush/config.rb', line 66

def perform_lists
  (1..priorities).collect { |num| "#{perform_namespace}:#{num}" }
end

#redisObject



59
60
61
62
63
64
# File 'lib/qpush/config.rb', line 59

def redis
  {
    size: redis_pool,
    url: redis_url
  }
end

#worker_optionsObject



44
45
46
47
48
49
50
# File 'lib/qpush/config.rb', line 44

def worker_options
  {
    perform_threads: perform_threads,
    queue_threads: queue_threads,
    delay_threads: delay_threads
  }
end