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

Class Method Summary collapse

Class Attribute Details

.after_job_forkObject

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_nameObject

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_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



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

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



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

def keep_parent_process_name
  @keep_parent_process_name
end

.loggerObject

 Set/return the logger object



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

def logger
  @logger
end

.max_job_retriesObject

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_foregroundObject

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_timeObject

 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(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



39
40
41
# File 'lib/steve.rb', line 39

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