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 +5 -5
- data/bin/sqs-grep +3 -0
- data/lib/sqs-grep/config.rb +2 -0
- data/lib/sqs-grep/runner.rb +24 -2
- data/lib/sqs-grep/version.rb +2 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58de437281552a856142c2f162e1e5f41156d291729d3073a7a9593ac7b5dcae
|
4
|
+
data.tar.gz: 3fefede13a54aa7a94c115ccd228581e522a450bcaea84f442987381ebe2da3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bdb63e13368f1e81a1a64b4706594eb7668a527b12538f9950b3a4301158007b6830d3e8899b21e93db3dadfed192eeac8b5d0ac902076025139aa860e60e22
|
7
|
+
data.tar.gz: 0d11fe9ca5573486795e19ae4b6c95a9c51d441c5c8fd9a15b15cb55bc6612bc8113797cdcce9d9b07150e548887876b4fd7aaf8a30a181c28d32e749390618d
|
data/bin/sqs-grep
CHANGED
@@ -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
|
data/lib/sqs-grep/config.rb
CHANGED
@@ -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
|
data/lib/sqs-grep/runner.rb
CHANGED
@@ -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 =
|
22
|
-
|
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
|
data/lib/sqs-grep/version.rb
CHANGED
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.
|
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:
|
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,
|
31
|
-
\
|
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.
|
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
|