Class: Stax::Cmd::Sqs

Inherits:
SubCommand show all
Defined in:
lib/stax/mixin/sqs.rb

Instance Method Summary collapse

Methods inherited from SubCommand

#info, stax_info, stax_info_tasks

Instance Method Details

#lsObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/stax/mixin/sqs.rb', line 21

def ls
  print_table stack_sqs_queues.map { |r|
    q = Aws::Sqs.get(r.physical_resource_id)
    [
      q['QueueArn'].split(':').last,
      q['ApproximateNumberOfMessages'],
      q['ApproximateNumberOfMessagesNotVisible'],
      Time.at(q['LastModifiedTimestamp'].to_i),
    ]
  }
end

#purgeObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/stax/mixin/sqs.rb', line 34

def purge
  stack_sqs_queues.each do |q|
    name = q.physical_resource_id.split('/').last
    if yes?("Purge queue #{name}?", :yellow)
      begin
        Aws::Sqs.purge(q.physical_resource_id)
      rescue ::Aws::SQS::Errors::PurgeQueueInProgress => e
        warn(e.message)
      end
    end
  end
end