Class: RailsCloudTasks::Adapter
- Inherits:
-
Object
- Object
- RailsCloudTasks::Adapter
- Defined in:
- lib/rails_cloud_tasks/adapter.rb
Instance Method Summary collapse
Instance Method Details
#client ⇒ Object
25 26 27 |
# File 'lib/rails_cloud_tasks/adapter.rb', line 25 def client @client ||= Google::Cloud::Tasks.cloud_tasks end |
#enqueue(job, timestamp = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rails_cloud_tasks/adapter.rb', line 7 def enqueue(job, = nil) path = client.queue_path(project: project_id, location: location_id, queue: job.queue_name) task = build_task(job, ) begin client.create_task(parent: path, task: task) rescue Google::Cloud::FailedPreconditionError => e raise e if e.details != 'Queue does not exist.' client.create_queue(build_queue(path)) retry end end |
#enqueue_at(job, timestamp) ⇒ Object
21 22 23 |
# File 'lib/rails_cloud_tasks/adapter.rb', line 21 def enqueue_at(job, ) enqueue(job, .to_i) end |