class Magellan::Gcs::Proxy::PubsubProgressNotifier
Attributes
topic_name[R]
Public Class Methods
new(topic_name)
click to toggle source
# File lib/magellan/gcs/proxy/pubsub_progress_notifier.rb, line 14 def initialize(topic_name) @topic_name = topic_name end
Public Instance Methods
notify(severity, job_message, data, attrs)
click to toggle source
# File lib/magellan/gcs/proxy/pubsub_progress_notifier.rb, line 22 def notify(severity, job_message, data, attrs) attrs = { level: severity, job_message_id: job_message.message_id }.merge(attrs) # attrs must be an [Hash<String,String>] attrs = attrs.each_with_object({}) { |(k, v), d| d[k.to_s] = v.to_s } logger.debug("Publishing progress: #{attrs.inspect}") msg = Google::Apis::PubsubV1::Message.new(data: data, attributes: attrs) req = Google::Apis::PubsubV1::PublishRequest.new(messages: [msg]) GCP.pubsub.publish_topic(topic_name, req) end
topic()
click to toggle source
# File lib/magellan/gcs/proxy/pubsub_progress_notifier.rb, line 18 def topic @topic ||= GCP.pubsub.topic(topic_name) end