Class: ActiveJob::GoogleCloudPubsub::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/activejob-google_cloud_pubsub/adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(pubsub: Google::Cloud::Pubsub.new) ⇒ Adapter

Returns a new instance of Adapter.



10
11
12
# File 'lib/activejob-google_cloud_pubsub/adapter.rb', line 10

def initialize(pubsub: Google::Cloud::Pubsub.new)
  @pubsub = pubsub
end

Instance Method Details

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



14
15
16
# File 'lib/activejob-google_cloud_pubsub/adapter.rb', line 14

def enqueue(job, attributes = {})
  @pubsub.topic_for(job.queue_name).publish JSON.dump(job.serialize), attributes
end

#enqueue_at(job, timestamp) ⇒ Object



18
19
20
# File 'lib/activejob-google_cloud_pubsub/adapter.rb', line 18

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