module Magellan::Gcs::Proxy::ProgressNotification
Public Instance Methods
build_notifier()
click to toggle source
Build the Notifier object like theseā¦
@notifiers: PubsubProgressNotifier ProgressNotifierAdapter @logger: CompositeLogger @loggers: Logger Google::Cloud::Logging::Logger
# 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()
click to toggle source
# File lib/magellan/gcs/proxy/progress_notification.rb, line 27 def notifier @notifier ||= build_notifier end
notify(progress, total, data, severity: :info)
click to toggle source
# File lib/magellan/gcs/proxy/progress_notification.rb, line 23 def notify(progress, total, data, severity: :info) notifier.notify(severity, message, data, progress: progress, total: total) end
process_with_notification(numbers, total, base_message, main = nil) { |self| ... }
click to toggle source
# File lib/magellan/gcs/proxy/progress_notification.rb, line 9 def process_with_notification(numbers, total, base_message, main = nil) start_no, complete_no, error_no = *numbers notify(start_no, total, "#{base_message} starting") begin main ? main.call(self) : yield(self) rescue => e notify(error_no, total, "#{base_message} error: [#{e.class}] #{e.message}", severity: :error) raise e unless main else notify(complete_no, total, "#{base_message} completed") yield(self) if main end end