Class: Async::Background::Queue::Client
- Inherits:
-
Object
- Object
- Async::Background::Queue::Client
- Includes:
- Clock
- Defined in:
- lib/async/background/queue/client.rb
Instance Method Summary collapse
-
#initialize(store:, notifier: nil) ⇒ Client
constructor
A new instance of Client.
- #push(class_name, args = EMPTY_ARGS, run_at = nil, options: EMPTY_OPTIONS) ⇒ Object
- #push_at(time, class_name, args = EMPTY_ARGS, options: EMPTY_OPTIONS) ⇒ Object
- #push_in(delay, class_name, args = EMPTY_ARGS, options: EMPTY_OPTIONS) ⇒ Object
Constructor Details
#initialize(store:, notifier: nil) ⇒ Client
Returns a new instance of Client.
12 13 14 15 |
# File 'lib/async/background/queue/client.rb', line 12 def initialize(store:, notifier: nil) @store = store @notifier = notifier end |
Instance Method Details
#push(class_name, args = EMPTY_ARGS, run_at = nil, options: EMPTY_OPTIONS) ⇒ Object
17 18 19 20 21 |
# File 'lib/async/background/queue/client.rb', line 17 def push(class_name, args = EMPTY_ARGS, run_at = nil, options: EMPTY_OPTIONS) id = @store.enqueue(class_name, args, run_at, options: ) @notifier&.notify_all id end |
#push_at(time, class_name, args = EMPTY_ARGS, options: EMPTY_OPTIONS) ⇒ Object
27 28 29 30 |
# File 'lib/async/background/queue/client.rb', line 27 def push_at(time, class_name, args = EMPTY_ARGS, options: EMPTY_OPTIONS) run_at = time.respond_to?(:to_f) ? time.to_f : time push(class_name, args, run_at, options: ) end |
#push_in(delay, class_name, args = EMPTY_ARGS, options: EMPTY_OPTIONS) ⇒ Object
23 24 25 |
# File 'lib/async/background/queue/client.rb', line 23 def push_in(delay, class_name, args = EMPTY_ARGS, options: EMPTY_OPTIONS) push(class_name, args, realtime_now + delay.to_f, options: ) end |