Class: ActiveJob::GoogleCloudPubsub::Adapter
- Inherits:
-
Object
- Object
- ActiveJob::GoogleCloudPubsub::Adapter
- Defined in:
- lib/activejob-google_cloud_pubsub/adapter.rb
Instance Method Summary collapse
- #enqueue(job, attributes = {}) ⇒ Object
- #enqueue_at(job, timestamp) ⇒ Object
-
#initialize(pubsub: Google::Cloud::Pubsub.new) ⇒ Adapter
constructor
A new instance of Adapter.
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, ) enqueue job, timestamp: end |