Module: Steve

Defined in:
lib/steve/job.rb,
lib/steve.rb,
lib/steve/worker.rb,
lib/steve/interface.rb,
lib/steve/queued_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: Interface, Job, QueuedJob, Worker

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.after_job_forkObject

Proc to run after forking



27
28
29
# File 'lib/steve.rb', line 27

def after_job_fork
  @after_job_fork
end

.default_job_priorityObject

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_queueObject

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_jobsObject

Delete jobs after successful completion



33
34
35
# File 'lib/steve.rb', line 33

def delete_successful_jobs
  @delete_successful_jobs
end

.jobs_table_nameObject

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_nameObject

Allow parent process name to be kept



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

def keep_parent_process_name
  @keep_parent_process_name
end

.loggerObject

 Set/return the logger object



18
19
20
# File 'lib/steve.rb', line 18

def logger
  @logger
end

.max_job_retriesObject

The maximum number of times to retry a job



21
22
23
# File 'lib/steve.rb', line 21

def max_job_retries
  @max_job_retries
end

.run_jobs_in_foregroundObject

Whether or not jobs should be queued or run in the background



24
25
26
# File 'lib/steve.rb', line 24

def run_jobs_in_foreground
  @run_jobs_in_foreground
end

.worker_sleep_timeObject

 The period of time to wait before looking for new jobs



15
16
17
# File 'lib/steve.rb', line 15

def worker_sleep_time
  @worker_sleep_time
end

Class Method Details

.log(message) ⇒ Object

Log a new message



46
47
48
49
# File 'lib/steve.rb', line 46

def log(message)
  message.gsub!(/(\[\d+\])/) { "\e[33m#{$1}\e[0m" }
  logger.info "\e[37m#{Time.now.utc.to_s(:db)}\e[0m #{message}"
end

.worker_nameObject

Return the worker name for this current process/host



36
37
38
# File 'lib/steve.rb', line 36

def worker_name
  "host:#{Socket.gethostname} pid:#{Process.pid}" rescue "pid:#{Process.pid}"
end