Module: FlightControl::Adapter
- Included in:
- ActiveJob::QueueAdapters::SolidQueueExt
- Defined in:
- lib/flight_control/adapter.rb
Instance Method Summary collapse
- #activating(&block) ⇒ Object
- #clear_queue(queue_name) ⇒ Object
- #discard_all_jobs(jobs_relation) ⇒ Object
- #discard_job(job, jobs_relation) ⇒ Object
- #dispatch_job(job, jobs_relation) ⇒ Object
- #exposes_workers? ⇒ Boolean
- #fetch_jobs(jobs_relation) ⇒ Object
- #find_job(job_id) ⇒ Object
-
#find_recurring_task(recurring_task_id) ⇒ Object
Returns a recurring task represented by a hash as indicated above.
-
#find_worker(worker_id) ⇒ Object
Returns a worker represented by a hash as indicated above.
- #jobs_count(jobs_relation) ⇒ Object
- #pause_queue(queue_name) ⇒ Object
- #queue_paused?(queue_name) ⇒ Boolean
- #queue_size(queue_name) ⇒ Object
-
#queues ⇒ Object
Returns an array with the list of queues.
-
#recurring_tasks ⇒ Object
Returns an array with the list of recurring tasks.
- #resume_queue(queue_name) ⇒ Object
- #retry_all_jobs(jobs_relation) ⇒ Object
- #retry_job(job, jobs_relation) ⇒ Object
-
#supported_job_filters(jobs_relation) ⇒ Object
List of filters supported natively.
- #supported_job_statuses ⇒ Object
- #supports_job_filter?(jobs_relation, filter) ⇒ Boolean
- #supports_job_status?(status) ⇒ Boolean
- #supports_queue_pausing? ⇒ Boolean
- #supports_recurring_tasks? ⇒ Boolean
-
#workers ⇒ Object
Returns an array with the list of workers.
Instance Method Details
#activating(&block) ⇒ Object
2 3 4 |
# File 'lib/flight_control/adapter.rb', line 2 def activating(&block) block.call end |
#clear_queue(queue_name) ⇒ Object
96 97 98 |
# File 'lib/flight_control/adapter.rb', line 96 def clear_queue(queue_name) raise_incompatible_adapter_error_from :clear_queue end |
#discard_all_jobs(jobs_relation) ⇒ Object
134 135 136 |
# File 'lib/flight_control/adapter.rb', line 134 def discard_all_jobs(jobs_relation) raise_incompatible_adapter_error_from :discard_all_jobs end |
#discard_job(job, jobs_relation) ⇒ Object
138 139 140 |
# File 'lib/flight_control/adapter.rb', line 138 def discard_job(job, jobs_relation) raise_incompatible_adapter_error_from :discard_job end |
#dispatch_job(job, jobs_relation) ⇒ Object
142 143 144 |
# File 'lib/flight_control/adapter.rb', line 142 def dispatch_job(job, jobs_relation) raise_incompatible_adapter_error_from :dispatch_job end |
#exposes_workers? ⇒ Boolean
28 29 30 |
# File 'lib/flight_control/adapter.rb', line 28 def exposes_workers? false end |
#fetch_jobs(jobs_relation) ⇒ Object
122 123 124 |
# File 'lib/flight_control/adapter.rb', line 122 def fetch_jobs(jobs_relation) raise_incompatible_adapter_error_from :fetch_jobs end |
#find_job(job_id) ⇒ Object
146 147 148 |
# File 'lib/flight_control/adapter.rb', line 146 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/flight_control/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
75 76 77 78 79 |
# File 'lib/flight_control/adapter.rb', line 75 def find_worker(worker_id) if exposes_workers? raise_incompatible_adapter_error_from :find_worker end end |
#jobs_count(jobs_relation) ⇒ Object
118 119 120 |
# File 'lib/flight_control/adapter.rb', line 118 def jobs_count(jobs_relation) raise_incompatible_adapter_error_from :jobs_count end |
#pause_queue(queue_name) ⇒ Object
100 101 102 103 104 |
# File 'lib/flight_control/adapter.rb', line 100 def pause_queue(queue_name) if supports_queue_pausing? raise_incompatible_adapter_error_from :pause_queue end end |
#queue_paused?(queue_name) ⇒ Boolean
112 113 114 115 116 |
# File 'lib/flight_control/adapter.rb', line 112 def queue_paused?(queue_name) if supports_queue_pausing? raise_incompatible_adapter_error_from :queue_paused? end end |
#queue_size(queue_name) ⇒ Object
92 93 94 |
# File 'lib/flight_control/adapter.rb', line 92 def queue_size(queue_name) raise_incompatible_adapter_error_from :queue_size end |
#queues ⇒ Object
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
}
88 89 90 |
# File 'lib/flight_control/adapter.rb', line 88 def queues raise_incompatible_adapter_error_from :queue_names end |
#recurring_tasks ⇒ Object
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/flight_control/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
106 107 108 109 110 |
# File 'lib/flight_control/adapter.rb', line 106 def resume_queue(queue_name) if supports_queue_pausing? raise_incompatible_adapter_error_from :resume_queue end end |
#retry_all_jobs(jobs_relation) ⇒ Object
126 127 128 |
# File 'lib/flight_control/adapter.rb', line 126 def retry_all_jobs(jobs_relation) raise_incompatible_adapter_error_from :retry_all_jobs end |
#retry_job(job, jobs_relation) ⇒ Object
130 131 132 |
# File 'lib/flight_control/adapter.rb', line 130 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/flight_control/adapter.rb', line 20 def supported_job_filters(jobs_relation) [] end |
#supported_job_statuses ⇒ Object
10 11 12 13 |
# File 'lib/flight_control/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
15 16 17 |
# File 'lib/flight_control/adapter.rb', line 15 def supports_job_filter?(jobs_relation, filter) supported_job_filters(jobs_relation).include?(filter) end |
#supports_job_status?(status) ⇒ Boolean
6 7 8 |
# File 'lib/flight_control/adapter.rb', line 6 def supports_job_status?(status) supported_job_statuses.include?(status) end |
#supports_queue_pausing? ⇒ Boolean
24 25 26 |
# File 'lib/flight_control/adapter.rb', line 24 def supports_queue_pausing? true end |
#supports_recurring_tasks? ⇒ Boolean
32 33 34 |
# File 'lib/flight_control/adapter.rb', line 32 def supports_recurring_tasks? false end |
#workers ⇒ Object
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: { ... }
}
68 69 70 71 72 |
# File 'lib/flight_control/adapter.rb', line 68 def workers if exposes_workers? raise_incompatible_adapter_error_from :workers end end |