module ActiveJob::GoogleCloudPubsub::PubsubExtension

Public Instance Methods

remaining_time_to_schedule() click to toggle source
# File lib/activejob_google_cloud_pubsub/pubsub_extension.rb, line 27
def remaining_time_to_schedule
  scheduled_at ? [(scheduled_at - Time.now).to_f.ceil, 0].max : 0
end
scheduled_at() click to toggle source
# File lib/activejob_google_cloud_pubsub/pubsub_extension.rb, line 21
def scheduled_at
  return nil unless (timestamp = attributes['timestamp'])

  Time.at(timestamp.to_f)
end
subscription_for(queue_name) click to toggle source
# File lib/activejob_google_cloud_pubsub/pubsub_extension.rb, line 13
def subscription_for(queue_name)
  name = "activejob-worker-#{queue_name}"

  subscription(name) || topic_for(queue_name).subscribe(name)
end
time_to_process?() click to toggle source
# File lib/activejob_google_cloud_pubsub/pubsub_extension.rb, line 31
def time_to_process?
  remaining_time_to_schedule.zero?
end
topic_for(queue_name) click to toggle source
# File lib/activejob_google_cloud_pubsub/pubsub_extension.rb, line 7
def topic_for(queue_name)
  name = "activejob-queue-#{queue_name}"

  topic(name) || create_topic(name)
end