lib/rails_cloud_tasks/adapter.rb in rails-cloud-tasks-0.0.6 vs lib/rails_cloud_tasks/adapter.rb in rails-cloud-tasks-0.0.7.pre.rc
- old
+ new
@@ -1,17 +1,11 @@
require 'google-cloud-tasks'
module RailsCloudTasks
class Adapter
- attr_reader :client
-
delegate :project_id, :location_id, :host, :tasks_path, :auth, to: 'RailsCloudTasks.config'
- def initialize(client = Google::Cloud::Tasks.cloud_tasks)
- @client = client
- end
-
def enqueue(job, timestamp = nil)
path = client.queue_path(project: project_id, location: location_id, queue: job.queue_name)
task = build_task(job, timestamp)
begin
@@ -24,9 +18,13 @@
end
end
def enqueue_at(job, timestamp)
enqueue(job, timestamp.to_i)
+ end
+
+ def client
+ @client ||= Google::Cloud::Tasks.cloud_tasks
end
private
def url