Module: Steve
- Defined in:
- lib/steve/job.rb,
lib/steve.rb,
lib/steve/worker.rb,
lib/steve/interface.rb,
lib/steve/queued_job.rb,
lib/steve/archived_job.rb
Overview
Jobs can inherit from this class to add useful functionality and avoid needing to specify an initializer for all your jobs.
Defined Under Namespace
Classes: ArchivedJob, Interface, Job, QueuedJob, Worker
Class Attribute Summary collapse
-
.after_job_fork ⇒ Object
Proc to run after forking.
-
.archived_jobs_table_name ⇒ Object
The name of the table where completed jobs are stored.
-
.default_job_priority ⇒ Object
The default priority for new jobs.
-
.default_job_queue ⇒ Object
The default queue for new jobs.
-
.delete_successful_jobs ⇒ Object
Delete jobs after successful completion.
-
.jobs_table_name ⇒ Object
The name of the table where jobs are stored (default ‘jobs’).
-
.keep_parent_process_name ⇒ Object
Allow parent process name to be kept.
-
.logger ⇒ Object
Set/return the logger object.
-
.max_job_retries ⇒ Object
The maximum number of times to retry a job.
-
.run_jobs_in_foreground ⇒ Object
Whether or not jobs should be queued or run in the background.
-
.worker_sleep_time ⇒ Object
The period of time to wait before looking for new jobs.
Class Method Summary collapse
-
.log(message) ⇒ Object
Log a new message.
-
.worker_name ⇒ Object
Return the worker name for this current process/host.
Class Attribute Details
.after_job_fork ⇒ Object
Proc to run after forking
30 31 32 |
# File 'lib/steve.rb', line 30 def after_job_fork @after_job_fork end |
.archived_jobs_table_name ⇒ Object
The name of the table where completed jobs are stored
15 16 17 |
# File 'lib/steve.rb', line 15 def archived_jobs_table_name @archived_jobs_table_name end |
.default_job_priority ⇒ Object
The default priority for new jobs
9 10 11 |
# File 'lib/steve.rb', line 9 def default_job_priority @default_job_priority end |
.default_job_queue ⇒ Object
The default queue for new jobs
6 7 8 |
# File 'lib/steve.rb', line 6 def default_job_queue @default_job_queue end |
.delete_successful_jobs ⇒ Object
Delete jobs after successful completion
36 37 38 |
# File 'lib/steve.rb', line 36 def delete_successful_jobs @delete_successful_jobs end |
.jobs_table_name ⇒ Object
The name of the table where jobs are stored (default ‘jobs’)
12 13 14 |
# File 'lib/steve.rb', line 12 def jobs_table_name @jobs_table_name end |
.keep_parent_process_name ⇒ Object
Allow parent process name to be kept
33 34 35 |
# File 'lib/steve.rb', line 33 def keep_parent_process_name @keep_parent_process_name end |
.logger ⇒ Object
Set/return the logger object
21 22 23 |
# File 'lib/steve.rb', line 21 def logger @logger end |
.max_job_retries ⇒ Object
The maximum number of times to retry a job
24 25 26 |
# File 'lib/steve.rb', line 24 def max_job_retries @max_job_retries end |
.run_jobs_in_foreground ⇒ Object
Whether or not jobs should be queued or run in the background
27 28 29 |
# File 'lib/steve.rb', line 27 def run_jobs_in_foreground @run_jobs_in_foreground end |
.worker_sleep_time ⇒ Object
The period of time to wait before looking for new jobs
18 19 20 |
# File 'lib/steve.rb', line 18 def worker_sleep_time @worker_sleep_time end |
Class Method Details
.log(message) ⇒ Object
Log a new message
49 50 51 52 |
# File 'lib/steve.rb', line 49 def log() .gsub!(/(\[\d+\])/) { "\e[33m#{$1}\e[0m" } logger.info "\e[37m#{Time.now.utc.to_s(:db)}\e[0m #{}" end |
.worker_name ⇒ Object
Return the worker name for this current process/host
39 40 41 |
# File 'lib/steve.rb', line 39 def worker_name "host:#{Socket.gethostname} pid:#{Process.pid}" rescue "pid:#{Process.pid}" end |