Class: Magellan::Gcs::Proxy::PubsubProgressNotifier
- Inherits:
-
Object
- Object
- Magellan::Gcs::Proxy::PubsubProgressNotifier
- Includes:
- Log
- Defined in:
- lib/magellan/gcs/proxy/pubsub_progress_notifier.rb
Constant Summary
Constants included from Log
Log::CLOUD_LOGGING_RESOURCE_KEYS
Instance Attribute Summary collapse
-
#topic_name ⇒ Object
readonly
Returns the value of attribute topic_name.
Instance Method Summary collapse
-
#initialize(topic_name) ⇒ PubsubProgressNotifier
constructor
A new instance of PubsubProgressNotifier.
- #notify(severity, job_message, data, attrs) ⇒ Object
- #topic ⇒ Object
Methods included from Log
build_cloud_logging_logger, build_logger, build_loggers, logger, loggers, verbose
Constructor Details
#initialize(topic_name) ⇒ PubsubProgressNotifier
Returns a new instance of PubsubProgressNotifier.
14 15 16 |
# File 'lib/magellan/gcs/proxy/pubsub_progress_notifier.rb', line 14 def initialize(topic_name) @topic_name = topic_name end |
Instance Attribute Details
#topic_name ⇒ Object (readonly)
Returns the value of attribute topic_name.
13 14 15 |
# File 'lib/magellan/gcs/proxy/pubsub_progress_notifier.rb', line 13 def topic_name @topic_name end |
Instance Method Details
#notify(severity, job_message, data, attrs) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/magellan/gcs/proxy/pubsub_progress_notifier.rb', line 22 def notify(severity, , data, attrs) attrs = { level: severity, job_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 |