Module: Magellan::Gcs::Proxy::ProgressNotification
Defined Under Namespace
Classes: CompositeNotifier
Constant Summary
Constants included from Log
Log::CLOUD_LOGGING_RESOURCE_KEYS
Instance Method Summary collapse
-
#build_notifier ⇒ Object
Build the Notifier object like these…
- #notifier ⇒ Object
- #notify(progress, total, data, severity: :info) ⇒ Object
- #process_with_notification(numbers, total, base_message, main = nil) ⇒ Object
Methods included from Log
build_cloud_logging_logger, build_logger, build_loggers, logger, loggers, verbose
Instance Method Details
#build_notifier ⇒ Object
Build the Notifier object like these…
CompositeNotifier
@notifiers:
PubsubProgressNotifier
ProgressNotifierAdapter
@logger:
CompositeLogger
@loggers:
Logger
Google::Cloud::Logging::Logger
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/magellan/gcs/proxy/progress_notification.rb', line 42 def build_notifier notifiers = [] if c = Proxy.config[:progress_notification] notifiers << PubsubProgressNotifier.new(c['topic']) end notifiers << ProgressNotifierAdapter.new(logger) case notifiers.length when 1 then notifiers.first else CompositeNotifier.new(notifiers) end end |
#notifier ⇒ Object
27 28 29 |
# File 'lib/magellan/gcs/proxy/progress_notification.rb', line 27 def notifier @notifier ||= build_notifier end |
#notify(progress, total, data, severity: :info) ⇒ Object
23 24 25 |
# File 'lib/magellan/gcs/proxy/progress_notification.rb', line 23 def notify(progress, total, data, severity: :info) notifier.notify(severity, , data, progress: progress, total: total) end |
#process_with_notification(numbers, total, base_message, main = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/magellan/gcs/proxy/progress_notification.rb', line 9 def process_with_notification(numbers, total, , main = nil) start_no, complete_no, error_no = *numbers notify(start_no, total, "#{} starting") begin main ? main.call(self) : yield(self) rescue => e notify(error_no, total, "#{} error: [#{e.class}] #{e.}", severity: :error) raise e unless main else notify(complete_no, total, "#{} completed") yield(self) if main end end |