sqs-grep 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 430d8f5c9160e24866f1043a578efce6e0f6dab0
4
- data.tar.gz: 5bc5ebd9d2d30c08afd5c49d8e7c3067de488841
2
+ SHA256:
3
+ metadata.gz: 58de437281552a856142c2f162e1e5f41156d291729d3073a7a9593ac7b5dcae
4
+ data.tar.gz: 3fefede13a54aa7a94c115ccd228581e522a450bcaea84f442987381ebe2da3c
5
5
  SHA512:
6
- metadata.gz: 3f1b6a9466474dc86e0ba31f67240bf7db9e6e725fd65da50d43744f859761afac4df57e07ce16db7f1c545bc5ff063f182b64c93edeaf1f6a7cc599a5b00aa0
7
- data.tar.gz: 537b6b051975c9a09b8f1d78e3beb3a939e5908fc070f8137441e457de3e8a282871856274c869d9f16f6efc55ac0389c085633200cc55f916420a0afbd44cc6
6
+ metadata.gz: 1bdb63e13368f1e81a1a64b4706594eb7668a527b12538f9950b3a4301158007b6830d3e8899b21e93db3dadfed192eeac8b5d0ac902076025139aa860e60e22
7
+ data.tar.gz: 0d11fe9ca5573486795e19ae4b6c95a9c51d441c5c8fd9a15b15cb55bc6612bc8113797cdcce9d9b07150e548887876b4fd7aaf8a30a181c28d32e749390618d
@@ -9,6 +9,9 @@ config = SqsGrep::Config.new
9
9
  opts_parser = OptionParser.new do |opts|
10
10
  opts.banner = "Usage: sqs-grep [OPTIONS] PATTERN QUEUE"
11
11
  opts.separator ""
12
+ opts.on("-s", "--send-to OTHER_QUEUE", "Send matched messages to another queue (same account and region)") do |q|
13
+ config.send_to = q
14
+ end
12
15
  opts.on("-d", "--delete", "Consume (delete) matched messages") do
13
16
  config.delete_matched = true
14
17
  end
@@ -4,6 +4,7 @@ module SqsGrep
4
4
  # Stronger builder pattern would be nice
5
5
  attr_accessor :client_options, :sqs_client,
6
6
  :pattern, :queue_name,
7
+ :send_to,
7
8
  :visibility_timeout,
8
9
  :wait_time_seconds,
9
10
  :max_count,
@@ -13,6 +14,7 @@ module SqsGrep
13
14
 
14
15
  def initialize
15
16
  @client_options = {}
17
+ @send_to = nil
16
18
  @visibility_timeout = 30
17
19
  @wait_time_seconds = 10
18
20
  @max_count = nil
@@ -18,8 +18,11 @@ module SqsGrep
18
18
  # Sets $stdout.sync
19
19
  def run
20
20
  queue_name = @config.queue_name
21
- queue_url = @config.sqs_client.list_queues(queue_name_prefix: queue_name).queue_urls.find {|url| File.basename(url) == queue_name}
22
- queue_url or raise "Can't find queue named #{queue_name.inspect}"
21
+ queue_url = resolve_queue queue_name
22
+
23
+ send_to_url = if @config.send_to
24
+ resolve_queue @config.send_to
25
+ end
23
26
 
24
27
  $stdout.sync = true
25
28
 
@@ -63,6 +66,18 @@ module SqsGrep
63
66
  puts ""
64
67
  end
65
68
 
69
+ if send_to_url
70
+ # FIXME? discards message attributes
71
+ send_res = @config.sqs_client.send_message(
72
+ queue_url: send_to_url,
73
+ message_body: m.body,
74
+ )
75
+ if !@config.json_format
76
+ p send_res
77
+ puts ""
78
+ end
79
+ end
80
+
66
81
  if @config.delete_matched
67
82
  delete_res = @config.sqs_client.delete_message(
68
83
  queue_url: queue_url,
@@ -87,6 +102,13 @@ module SqsGrep
87
102
  return 0
88
103
  end
89
104
 
105
+ private
106
+
107
+ def resolve_queue(queue_name)
108
+ @config.sqs_client.list_queues(queue_name_prefix: queue_name).queue_urls.find {|url| File.basename(url) == queue_name} \
109
+ or raise "Can't find queue named #{queue_name.inspect}"
110
+ end
111
+
90
112
  end
91
113
 
92
114
  end
@@ -1,3 +1,4 @@
1
1
  module SqsGrep
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
+ DATE = '2018-02-25'
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqs-grep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rachel Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2018-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -27,8 +27,9 @@ dependencies:
27
27
  description: "\n sqs-grep iterates through each message on the given SQS queue,
28
28
  testing its\n body against the given regular expression, displaying matching
29
29
  messages to\n standard output.\n\n Options are available to control match
30
- inversion, json output, deletion of\n matching messages, match limits, and timeouts.\n\n
31
- \ Respects $https_proxy.\n "
30
+ inversion, json output, deletion of\n matching messages, match limits, sending
31
+ the messages to another queue,\n and timeouts.\n\n Respects $https_proxy.\n
32
+ \ "
32
33
  email: sqs-grep-git@rve.org.uk
33
34
  executables:
34
35
  - sqs-grep
@@ -61,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  version: '0'
62
63
  requirements: []
63
64
  rubyforge_project:
64
- rubygems_version: 2.5.1
65
+ rubygems_version: 2.7.6
65
66
  signing_key:
66
67
  specification_version: 4
67
68
  summary: Find messages on an SQS queue by regular expression, and optionally delete