Class: ActiveJob::GoogleCloudTasks::HTTP::Adapter

Inherits:
Object
  • Object
show all
Includes:
Inlining
Defined in:
lib/active_job/google_cloud_tasks/http/adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(project:, location:, url:, task_options: {}, client: nil) ⇒ Adapter

Returns a new instance of Adapter.



9
10
11
12
13
14
15
# File 'lib/active_job/google_cloud_tasks/http/adapter.rb', line 9

def initialize(project:, location:, url:, task_options: {}, client: nil)
  @project = project
  @location = location
  @url = url
  @task_options = task_options
  @client = client
end

Instance Method Details

#enqueue(job, attributes = {}) ⇒ Object



17
18
19
20
21
22
# File 'lib/active_job/google_cloud_tasks/http/adapter.rb', line 17

def enqueue(job, attributes = {})
  path = client.queue_path(project: @project, location: @location, queue: job.queue_name)
  task = build_task(job, attributes)

  client.create_task parent: path, task: task
end

#enqueue_at(job, scheduled_at) ⇒ Object



24
25
26
# File 'lib/active_job/google_cloud_tasks/http/adapter.rb', line 24

def enqueue_at(job, scheduled_at)
  enqueue job, scheduled_at: scheduled_at
end