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.



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

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



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

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

  client.create_task path, task
end

#enqueue_at(job, scheduled_at) ⇒ Object



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

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