Parent

Methods

Class/Module Index [+]

Quicksearch

Backup::Notifier::Base

Attributes

max_retries[RW]

Number of times to retry failed attempts to send notification. Default: 10

model[R]
notify_on_failure?[RW]

When set to true, the user will be notified by email when a backup process raises an exception before finishing

notify_on_success?[RW]

When set to true, the user will be notified by email when a backup process ends without raising any exceptions

notify_on_warning?[RW]

When set to true, the user will be notified by email when a backup process is successful, but has warnings

on_failure[RW]

When set to true, the user will be notified by email when a backup process raises an exception before finishing

on_success[RW]

When set to true, the user will be notified by email when a backup process ends without raising any exceptions

on_warning[RW]

When set to true, the user will be notified by email when a backup process is successful, but has warnings

retry_waitsec[RW]

Time in seconds to pause before each retry. Default: 30

Public Class Methods

new(model) click to toggle source
# File lib/backup/notifier/base.rb, line 40
def initialize(model)
  @model = model
  load_defaults!

  @on_success = true if on_success.nil?
  @on_warning = true if on_warning.nil?
  @on_failure = true if on_failure.nil?
  @max_retries    ||= 10
  @retry_waitsec  ||= 30
end

Public Instance Methods

perform!() click to toggle source

This method is called from an ensure block in Model#perform! and must not raise any exceptions. However, each Notifier’s notify! method should raise an exception if the request fails so it may be retried.

# File lib/backup/notifier/base.rb, line 54
def perform!
  status = case model.exit_status
           when 0
             :success if notify_on_success?
           when 1
             :warning if notify_on_success? || notify_on_warning?
           else
             :failure if notify_on_failure?
           end

  if status
    Logger.info "Sending notification using #{ notifier_name }..."
    with_retries { notify!(status) }
  end

rescue Exception => err
  Logger.error Error.wrap(err, "#{ notifier_name } Failed!")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.