Class: Mammoth::DeadLetterCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/mammoth/dead_letter_commands.rb

Overview

Operator commands for inspecting and replaying dead letters. rubocop:disable Metrics/ClassLength

Defined Under Namespace

Classes: DEAD_LETTER_TRANSACTION_ENVELOPE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, lifecycle_hooks: LifecycleHooks.new) ⇒ DeadLetterCommands

Returns a new instance of DeadLetterCommands.

Parameters:

  • argv (Array<String>)

    command line arguments

  • lifecycle_hooks (Mammoth::LifecycleHooks, Hash) (defaults to: LifecycleHooks.new)

    local lifecycle callbacks



29
30
31
32
# File 'lib/mammoth/dead_letter_commands.rb', line 29

def initialize(argv, lifecycle_hooks: LifecycleHooks.new)
  @argv = argv
  @lifecycle_hooks = lifecycle_hooks.is_a?(LifecycleHooks) ? lifecycle_hooks : LifecycleHooks.new(lifecycle_hooks)
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



20
21
22
# File 'lib/mammoth/dead_letter_commands.rb', line 20

def argv
  @argv
end

#lifecycle_hooksObject (readonly)

Returns the value of attribute lifecycle_hooks.



20
21
22
# File 'lib/mammoth/dead_letter_commands.rb', line 20

def lifecycle_hooks
  @lifecycle_hooks
end

Class Method Details

.call(argv, lifecycle_hooks: LifecycleHooks.new) ⇒ Object

Parameters:

  • argv (Array<String>)

    command line arguments



23
24
25
# File 'lib/mammoth/dead_letter_commands.rb', line 23

def self.call(argv, lifecycle_hooks: LifecycleHooks.new)
  new(argv, lifecycle_hooks: lifecycle_hooks).call
end

Instance Method Details

#callInteger

Dispatch the nested dead-letter subcommand.

Returns:

  • (Integer)

    process status code



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mammoth/dead_letter_commands.rb', line 37

def call
  case command
  when "list" then list
  when "show" then show
  when "replay" then replay
  else
    raise ConfigurationError, "dead-letters subcommand required\n#{CLI::USAGE}"
  end
rescue Mammoth::Error => e
  warn e.message
  1
end