Module: QC::Config

Included in:
QC
Defined in:
lib/queue_classic/config.rb

Instance Method Summary collapse

Instance Method Details

#app_nameObject

You can use the APP_NAME to query for postgres related process information in the pg_stat_activity table.



8
9
10
# File 'lib/queue_classic/config.rb', line 8

def app_name
  @app_name ||= ENV["QC_APP_NAME"] || "queue_classic"
end

#default_queueObject

The default queue used by ‘QC.enqueue`.



31
32
33
# File 'lib/queue_classic/config.rb', line 31

def default_queue
  @default_queue ||= Queue.new(QC.queue)
end

#default_queue=(queue) ⇒ Object



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

def default_queue=(queue)
  @default_queue = queue
end

#default_worker_classObject

The worker class instantiated by QC’s rake tasks.



62
63
64
65
66
# File 'lib/queue_classic/config.rb', line 62

def default_worker_class
  @worker_class ||= (ENV["QC_DEFAULT_WORKER_CLASS"] && Kernel.const_get(ENV["QC_DEFAULT_WORKER_CLASS"]) ||
                     QC::Worker)

end

#default_worker_class=(worker_class) ⇒ Object



68
69
70
# File 'lib/queue_classic/config.rb', line 68

def default_worker_class=(worker_class)
  @worker_class = worker_class
end

#fork_worker?Boolean

Set this variable if you wish for the worker to fork a UNIX process for each locked job. Remember to re-establish any database connections. See the worker for more details.

Returns:

  • (Boolean)


57
58
59
# File 'lib/queue_classic/config.rb', line 57

def fork_worker?
  @fork_worker ||= (!ENV["QC_FORK_WORKER"].nil?)
end

#queueObject



26
27
28
# File 'lib/queue_classic/config.rb', line 26

def queue
  @queue = ENV["QUEUE"] || "default"
end

#queuesObject

Each row in the table will have a column that notes the queue. You can point your workers at different queues.



42
43
44
# File 'lib/queue_classic/config.rb', line 42

def queues
  @queues ||= (ENV["QUEUES"] && ENV["QUEUES"].split(",").map(&:strip)) || []
end

#reset_configObject

reset memoized configuration



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/queue_classic/config.rb', line 73

def reset_config
  # TODO: we might want to think about storing these in a Hash.
  @app_name = nil
  @wait_time = nil
  @table_name = nil
  @queue = nil
  @default_queue = nil
  @queues = nil
  @top_bound = nil
  @fork_worker = nil
  @worker_class = nil
end

#table_nameObject

Why do you want to change the table name? Just deal with the default OK? If you do want to change this, you will need to update the PL/pgSQL lock_head() function. Come on. Don’t do it.… Just stick with the default.



22
23
24
# File 'lib/queue_classic/config.rb', line 22

def table_name
  @table_name ||= "queue_classic_jobs"
end

#top_boundObject

Set this to 1 for strict FIFO. There is nothing special about 9.…



48
49
50
# File 'lib/queue_classic/config.rb', line 48

def top_bound
  @top_bound ||= (ENV["QC_TOP_BOUND"] || 9).to_i
end

#wait_timeObject

Number of seconds to block on the listen chanel for new jobs.



13
14
15
# File 'lib/queue_classic/config.rb', line 13

def wait_time
  @wait_time ||= (ENV["QC_LISTEN_TIME"] || 5).to_i
end