Class: Magellan::Gcs::Proxy::PubsubProgressNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/magellan/gcs/proxy/pubsub_progress_notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic_name) ⇒ PubsubProgressNotifier

Returns a new instance of PubsubProgressNotifier.



11
12
13
# File 'lib/magellan/gcs/proxy/pubsub_progress_notifier.rb', line 11

def initialize(topic_name)
  @topic_name = topic_name
end

Instance Attribute Details

#topic_nameObject (readonly)

Returns the value of attribute topic_name.



10
11
12
# File 'lib/magellan/gcs/proxy/pubsub_progress_notifier.rb', line 10

def topic_name
  @topic_name
end

Instance Method Details

#notify(severity, job_message, data, attrs) ⇒ Object



19
20
21
# File 'lib/magellan/gcs/proxy/pubsub_progress_notifier.rb', line 19

def notify(severity, job_message, data, attrs)
  topic.publish data, { level: severity, job_message_id: job_message.message_id }.merge(attrs)
end

#topicObject



15
16
17
# File 'lib/magellan/gcs/proxy/pubsub_progress_notifier.rb', line 15

def topic
  @topic ||= GCP.pubsub.topic(topic_name)
end