Class: Qurd::Action Abstract

Inherits:
Object
  • Object
show all
Extended by:
Mixins::AwsClients, Mixins::Configuration
Includes:
Mixins::AwsClients, Mixins::Configuration
Defined in:
lib/qurd/action.rb,
lib/qurd/action/chef.rb,
lib/qurd/action/dummy.rb,
lib/qurd/action/route53.rb

Overview

This class is abstract.

Subclass and override #launch, #launch_error, #terminate, #terminate_error, and #test, optionally override class method #Qurd#Qurd::Action#Qurd::Action.configure and instance methods #run_before and #run_after

Direct Known Subclasses

Chef, Dummy, Route53

Defined Under Namespace

Classes: Chef, Dummy, InvalidMessage, Route53

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Configuration

qurd_config, qurd_configuration, qurd_logger, qurd_logger!

Methods included from Mixins::AwsClients

aws_client, aws_retryable

Constructor Details

#initialize(message) ⇒ Action

Run the plugin for a given Message

Parameters:

Raises:

See Also:



40
41
42
43
44
45
46
47
# File 'lib/qurd/action.rb', line 40

def initialize(message)
  unless message.is_a?(Qurd::Message)
    qurd_logger!("Message is not a Qurd::Message (#{message.class})",
                 Qurd::Action::InvalidMessage)
  end
  @message = message
  @context = message.context
end

Instance Attribute Details

#contextCabin::Context (readonly)

The logging context

Returns:

  • (Cabin::Context)


26
27
28
# File 'lib/qurd/action.rb', line 26

def context
  @context
end

#messageObject (readonly)

Returns the value of attribute message.



26
# File 'lib/qurd/action.rb', line 26

attr_reader :context, :message

Class Method Details

.configure(_action) ⇒ Object

Optionally configure the plugin launch, launch_error, terminate, terminate_error, or test

Parameters:

  • _action (String)

    optionally configure, based on the actions



31
32
33
# File 'lib/qurd/action.rb', line 31

def self.configure(_action)
  qurd_logger.debug('Nothing to do')
end

Instance Method Details

#aws_credentialsAws::Credentials

Aws credentials for the message

Returns:

  • (Aws::Credentials)


57
58
59
# File 'lib/qurd/action.rb', line 57

def aws_credentials
  message.aws_credentials
end

#inspectObject



82
83
84
85
86
87
88
89
90
# File 'lib/qurd/action.rb', line 82

def inspect
  format('<%s:%x instance_id:%s message_id:%s context:%s>',
         self.class,
         object_id,
         message.instance_id,
         message.message_id,
         context.inspect
  )
end

#launchObject Also known as: launch_error, terminate, terminate_error, test

Run the plugin



68
69
70
# File 'lib/qurd/action.rb', line 68

def launch
  qurd_logger!("Override the abstract method #{__method__}")
end

#regionString

Aws region for the message

Returns:



51
52
53
# File 'lib/qurd/action.rb', line 51

def region
  message.region
end

#run_afterObject

Executed after the processor runs the plugins for an action

See Also:



78
79
80
# File 'lib/qurd/action.rb', line 78

def run_after
  qurd_logger.debug('Nothing to do')
end

#run_beforeObject

Executed before the processor runs the plugins for an action

See Also:



63
64
65
# File 'lib/qurd/action.rb', line 63

def run_before
  qurd_logger.debug('Nothing to do')
end