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 = [], run_at = nil, options: {}) ⇒ Object
- #push_at(time, class_name, args = [], options: {}) ⇒ Object
- #push_in(delay, class_name, args = [], options: {}) ⇒ Object
Constructor Details
#initialize(store:, notifier: nil) ⇒ Client
Returns a new instance of Client.
13 14 15 16 |
# File 'lib/async/background/queue/client.rb', line 13 def initialize(store:, notifier: nil) @store = store @notifier = notifier end |
Instance Method Details
#push(class_name, args = [], run_at = nil, options: {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/async/background/queue/client.rb', line 18 def push(class_name, args = [], run_at = nil, options: {}) id = @store.enqueue(class_name, args, run_at, options: ) @notifier&.notify_all id end |
#push_at(time, class_name, args = [], options: {}) ⇒ Object
29 30 31 32 |
# File 'lib/async/background/queue/client.rb', line 29 def push_at(time, class_name, args = [], 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 = [], options: {}) ⇒ Object
24 25 26 27 |
# File 'lib/async/background/queue/client.rb', line 24 def push_in(delay, class_name, args = [], options: {}) run_at = realtime_now + delay.to_f push(class_name, args, run_at, options: ) end |