Module: MissionControl::Jobs::Adapter

Instance Method Summary collapse

Instance Method Details

#activating(&block) ⇒ Object



2
3
4
# File 'lib/mission_control/jobs/adapter.rb', line 2

def activating(&block)
  block.call
end

#clear_queue(queue_name) ⇒ Object



98
99
100
# File 'lib/mission_control/jobs/adapter.rb', line 98

def clear_queue(queue_name)
  raise_incompatible_adapter_error_from :clear_queue
end

#discard_all_jobs(jobs_relation) ⇒ Object



136
137
138
# File 'lib/mission_control/jobs/adapter.rb', line 136

def discard_all_jobs(jobs_relation)
  raise_incompatible_adapter_error_from :discard_all_jobs
end

#discard_job(job, jobs_relation) ⇒ Object



140
141
142
# File 'lib/mission_control/jobs/adapter.rb', line 140

def discard_job(job, jobs_relation)
  raise_incompatible_adapter_error_from :discard_job
end

#dispatch_job(job, jobs_relation) ⇒ Object



144
145
146
# File 'lib/mission_control/jobs/adapter.rb', line 144

def dispatch_job(job, jobs_relation)
  raise_incompatible_adapter_error_from :dispatch_job
end

#exposes_workers?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/mission_control/jobs/adapter.rb', line 28

def exposes_workers?
  false
end

#fetch_jobs(jobs_relation) ⇒ Object



124
125
126
# File 'lib/mission_control/jobs/adapter.rb', line 124

def fetch_jobs(jobs_relation)
  raise_incompatible_adapter_error_from :fetch_jobs
end

#find_job(job_id) ⇒ Object



148
149
150
# File 'lib/mission_control/jobs/adapter.rb', line 148

def find_job(job_id, *)
  raise_incompatible_adapter_error_from :find_job
end

#find_recurring_task(recurring_task_id) ⇒ Object

Returns a recurring task represented by a hash as indicated above



52
53
54
55
56
# File 'lib/mission_control/jobs/adapter.rb', line 52

def find_recurring_task(recurring_task_id)
  if supports_recurring_tasks?
    raise_incompatible_adapter_error_from :find_recurring_task
  end
end

#find_worker(worker_id) ⇒ Object

Returns a worker represented by a hash as indicated above



76
77
78
79
80
# File 'lib/mission_control/jobs/adapter.rb', line 76

def find_worker(worker_id)
  if exposes_workers?
    raise_incompatible_adapter_error_from :find_worker
  end
end

#jobs_count(jobs_relation) ⇒ Object



120
121
122
# File 'lib/mission_control/jobs/adapter.rb', line 120

def jobs_count(jobs_relation)
  raise_incompatible_adapter_error_from :jobs_count
end

#pause_queue(queue_name) ⇒ Object



102
103
104
105
106
# File 'lib/mission_control/jobs/adapter.rb', line 102

def pause_queue(queue_name)
  if supports_queue_pausing?
    raise_incompatible_adapter_error_from :pause_queue
  end
end

#queue_paused?(queue_name) ⇒ Boolean

Returns:

  • (Boolean)


114
115
116
117
118
# File 'lib/mission_control/jobs/adapter.rb', line 114

def queue_paused?(queue_name)
  if supports_queue_pausing?
    raise_incompatible_adapter_error_from :queue_paused?
  end
end

#queue_size(queue_name) ⇒ Object



94
95
96
# File 'lib/mission_control/jobs/adapter.rb', line 94

def queue_size(queue_name)
  raise_incompatible_adapter_error_from :queue_size
end

#queuesObject

Returns an array with the list of queues. Each queue is represented as a hash with these attributes:

{
  name: "queue_name",
  size: 1,
  active: true
}


90
91
92
# File 'lib/mission_control/jobs/adapter.rb', line 90

def queues
  raise_incompatible_adapter_error_from :queue_names
end

#recurring_tasksObject

Returns an array with the list of recurring tasks. Each task is represented as a hash with these attributes:

{
  id: "periodic-job",
  job_class_name: "MyJob",
  arguments: [ 123, { arg: :value }]
  schedule: "every monday at 9 am",
  last_enqueued_at: Fri, 26 Jan 2024 20:31:09.652174000 UTC +00:00,
}


45
46
47
48
49
# File 'lib/mission_control/jobs/adapter.rb', line 45

def recurring_tasks
  if supports_recurring_tasks?
    raise_incompatible_adapter_error_from :recurring_tasks
  end
end

#resume_queue(queue_name) ⇒ Object



108
109
110
111
112
# File 'lib/mission_control/jobs/adapter.rb', line 108

def resume_queue(queue_name)
  if supports_queue_pausing?
    raise_incompatible_adapter_error_from :resume_queue
  end
end

#retry_all_jobs(jobs_relation) ⇒ Object



128
129
130
# File 'lib/mission_control/jobs/adapter.rb', line 128

def retry_all_jobs(jobs_relation)
  raise_incompatible_adapter_error_from :retry_all_jobs
end

#retry_job(job, jobs_relation) ⇒ Object



132
133
134
# File 'lib/mission_control/jobs/adapter.rb', line 132

def retry_job(job, jobs_relation)
  raise_incompatible_adapter_error_from :retry_job
end

#supported_job_filters(jobs_relation) ⇒ Object

List of filters supported natively. Non-supported filters are done in memory.



20
21
22
# File 'lib/mission_control/jobs/adapter.rb', line 20

def supported_job_filters(jobs_relation)
  []
end

#supported_job_statusesObject



10
11
12
13
# File 'lib/mission_control/jobs/adapter.rb', line 10

def supported_job_statuses
  # All adapters need to support these at a minimum
  [ :pending, :failed ]
end

#supports_job_filter?(jobs_relation, filter) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/mission_control/jobs/adapter.rb', line 15

def supports_job_filter?(jobs_relation, filter)
  supported_job_filters(jobs_relation).include?(filter)
end

#supports_job_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/mission_control/jobs/adapter.rb', line 6

def supports_job_status?(status)
  supported_job_statuses.include?(status)
end

#supports_queue_pausing?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/mission_control/jobs/adapter.rb', line 24

def supports_queue_pausing?
  true
end

#supports_recurring_tasks?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/mission_control/jobs/adapter.rb', line 32

def supports_recurring_tasks?
  false
end

#workersObject

Returns an array with the list of workers. Each worker is represented as a hash with these attributes:

{
  id: 123,
  name: "worker-name",
  hostname: "hey-default-101",
  last_heartbeat_at: Fri, 26 Jan 2024 20:31:09.652174000 UTC +00:00,
  configuration: { ... }
  raw_data: { ... }
}


69
70
71
72
73
# File 'lib/mission_control/jobs/adapter.rb', line 69

def workers
  if exposes_workers?
    raise_incompatible_adapter_error_from :workers
  end
end