Class: JobWorkflow::QueueAdapters::NullAdapter
- Defined in:
- lib/job_workflow/queue_adapters/null_adapter.rb
Overview
rubocop:disable Naming/PredicateMethod
Instance Method Summary collapse
-
#clear_queue(queue_name) ⇒ Object
: (String) -> bool.
-
#enqueue_test_job(queue_name, job) ⇒ Object
: (String, untyped) -> void.
-
#fetch_job_contexts(_job_ids) ⇒ Object
: (Array) -> Array[Hash[String, untyped]].
-
#fetch_job_statuses(_job_ids) ⇒ Object
: (Array) -> Hash[String, untyped].
-
#find_job(job_id) ⇒ Object
: (String) -> Hash[String, untyped]?.
-
#initialize ⇒ NullAdapter
constructor
rubocop:disable Lint/MissingSuper.
-
#initialize_adapter! ⇒ Object
: () -> void.
-
#job_status(_job) ⇒ Object
: (untyped) -> Symbol.
-
#pause_queue(queue_name) ⇒ Object
: (String) -> bool.
-
#paused_queues ⇒ Object
: () -> Array.
-
#queue_latency(_queue_name) ⇒ Object
: (String) -> Integer?.
-
#queue_paused?(queue_name) ⇒ Boolean
: (String) -> bool.
-
#queue_size(queue_name) ⇒ Object
: (String) -> Integer.
-
#reschedule_job(_job, _wait) ⇒ Object
: (DSL, Numeric) -> bool.
-
#reset! ⇒ Object
: () -> void.
-
#resume_queue(queue_name) ⇒ Object
: (String) -> bool.
-
#semaphore_available? ⇒ Boolean
: () -> bool.
-
#semaphore_signal(_semaphore) ⇒ Object
: (Semaphore) -> bool.
-
#semaphore_wait(_semaphore) ⇒ Object
: (Semaphore) -> bool.
-
#store_job(job_id, job_data) ⇒ Object
: (String, Hash[String, untyped]) -> void.
-
#supports_concurrency_limits? ⇒ Boolean
: () -> bool.
Methods inherited from Abstract
Constructor Details
#initialize ⇒ NullAdapter
rubocop:disable Lint/MissingSuper
10 11 12 13 14 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 10 def initialize # rubocop:disable Lint/MissingSuper @paused_queues = Set.new #: Set[String] @queue_jobs = {} #: Hash[String, Array[untyped]] @stored_jobs = {} #: Hash[String, Hash[String, untyped]] end |
Instance Method Details
#clear_queue(queue_name) ⇒ Object
: (String) -> bool
82 83 84 85 86 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 82 def clear_queue(queue_name) empty_jobs = [] #: Array[untyped] @queue_jobs[queue_name] = empty_jobs true end |
#enqueue_test_job(queue_name, job) ⇒ Object
Test helpers
: (String, untyped) -> void
106 107 108 109 110 111 112 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 106 def enqueue_test_job(queue_name, job) unless @queue_jobs.key?(queue_name) empty_jobs = [] #: Array[untyped] @queue_jobs[queue_name] = empty_jobs end @queue_jobs[queue_name] << job end |
#fetch_job_contexts(_job_ids) ⇒ Object
: (Array) -> Array[Hash[String, untyped]]
94 95 96 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 94 def fetch_job_contexts(_job_ids) [] end |
#fetch_job_statuses(_job_ids) ⇒ Object
: (Array) -> Hash[String, untyped]
32 33 34 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 32 def fetch_job_statuses(_job_ids) {} end |
#find_job(job_id) ⇒ Object
: (String) -> Hash[String, untyped]?
89 90 91 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 89 def find_job(job_id) @stored_jobs[job_id] end |
#initialize_adapter! ⇒ Object
: () -> void
8 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 8 def initialize_adapter!; end |
#job_status(_job) ⇒ Object
: (untyped) -> Symbol
37 38 39 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 37 def job_status(_job) :pending end |
#pause_queue(queue_name) ⇒ Object
: (String) -> bool
47 48 49 50 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 47 def pause_queue(queue_name) @paused_queues.add(queue_name) true end |
#paused_queues ⇒ Object
: () -> Array
64 65 66 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 64 def paused_queues @paused_queues.to_a end |
#queue_latency(_queue_name) ⇒ Object
: (String) -> Integer?
69 70 71 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 69 def queue_latency(_queue_name) nil end |
#queue_paused?(queue_name) ⇒ Boolean
: (String) -> bool
59 60 61 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 59 def queue_paused?(queue_name) @paused_queues.include?(queue_name) end |
#queue_size(queue_name) ⇒ Object
: (String) -> Integer
74 75 76 77 78 79 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 74 def queue_size(queue_name) jobs = @queue_jobs[queue_name] return 0 if jobs.nil? jobs.size end |
#reschedule_job(_job, _wait) ⇒ Object
: (DSL, Numeric) -> bool
99 100 101 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 99 def reschedule_job(_job, _wait) false end |
#reset! ⇒ Object
Test helpers
: () -> void
124 125 126 127 128 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 124 def reset! @paused_queues.clear @queue_jobs.clear @stored_jobs.clear end |
#resume_queue(queue_name) ⇒ Object
: (String) -> bool
53 54 55 56 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 53 def resume_queue(queue_name) @paused_queues.delete(queue_name) true end |
#semaphore_available? ⇒ Boolean
: () -> bool
17 18 19 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 17 def semaphore_available? false end |
#semaphore_signal(_semaphore) ⇒ Object
: (Semaphore) -> bool
27 28 29 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 27 def semaphore_signal(_semaphore) true end |
#semaphore_wait(_semaphore) ⇒ Object
: (Semaphore) -> bool
22 23 24 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 22 def semaphore_wait(_semaphore) true end |
#store_job(job_id, job_data) ⇒ Object
Test helpers - stores job data for find_job
: (String, Hash[String, untyped]) -> void
117 118 119 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 117 def store_job(job_id, job_data) @stored_jobs[job_id] = job_data end |
#supports_concurrency_limits? ⇒ Boolean
: () -> bool
42 43 44 |
# File 'lib/job_workflow/queue_adapters/null_adapter.rb', line 42 def supports_concurrency_limits? false end |