sqs-grep 0.1.2 → 0.1.3
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 +4 -4
- data/bin/sqs-grep +3 -0
- data/lib/sqs-grep/config.rb +4 -0
- data/lib/sqs-grep/runner.rb +20 -0
- data/lib/sqs-grep/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfabc562e28074e3dc85947047d7dd251abe00839bfaab16a60beaf563024ec0
|
4
|
+
data.tar.gz: 49abb2fc2e1e7a8a206ac882702a8907a316b1de77ddc5ac8e4188ac166280f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ab05bc4c6a6491f1f98e2355b283889590cd93ee64043d56605961a2da8a6a1396f7cc36308fd6afee8ef1d80bd6cd15fab610c4e18c555f5bc9a643c64cb6
|
7
|
+
data.tar.gz: 82a5193f904ef00ced6a7758de7d1cd6381b6624a117fa237379a06e755eaf5a44167d9ee3611d85830e39f1934a5f75c6b868cd8ae2dca0a14fe7a00e97471d
|
data/bin/sqs-grep
CHANGED
@@ -12,6 +12,9 @@ opts_parser = OptionParser.new do |opts|
|
|
12
12
|
opts.on("-s", "--send-to OTHER_QUEUE", "Send matched messages to another queue (same account and region)") do |q|
|
13
13
|
config.send_to = q
|
14
14
|
end
|
15
|
+
opts.on("-l", "--invoke-lambda FUNCTION_NAME", "Invoke a lambda with the contents of each message (same account and region)") do |l|
|
16
|
+
config.invoke_lambda = l
|
17
|
+
end
|
15
18
|
opts.on("-d", "--delete", "Consume (delete) matched messages") do
|
16
19
|
config.delete_matched = true
|
17
20
|
end
|
data/lib/sqs-grep/config.rb
CHANGED
@@ -5,6 +5,8 @@ module SqsGrep
|
|
5
5
|
attr_accessor :client_options, :sqs_client,
|
6
6
|
:pattern, :queue_name,
|
7
7
|
:send_to,
|
8
|
+
:invoke_lambda,
|
9
|
+
:lambda_client,
|
8
10
|
:visibility_timeout,
|
9
11
|
:wait_time_seconds,
|
10
12
|
:max_count,
|
@@ -15,6 +17,8 @@ module SqsGrep
|
|
15
17
|
def initialize
|
16
18
|
@client_options = {}
|
17
19
|
@send_to = nil
|
20
|
+
@invoke_lambda = nil
|
21
|
+
@lambda_client = nil
|
18
22
|
@visibility_timeout = 30
|
19
23
|
@wait_time_seconds = 10
|
20
24
|
@max_count = nil
|
data/lib/sqs-grep/runner.rb
CHANGED
@@ -13,12 +13,20 @@ module SqsGrep
|
|
13
13
|
effective_options = SqsGrep::Client.core_v2_options.merge(config.client_options)
|
14
14
|
Aws::SQS::Client.new(effective_options)
|
15
15
|
end
|
16
|
+
|
17
|
+
if @config.invoke_lambda
|
18
|
+
@config.lambda_client ||= begin
|
19
|
+
effective_options = SqsGrep::Client.core_v2_options.merge(config.client_options)
|
20
|
+
Aws::Lambda::Client.new(effective_options)
|
21
|
+
end
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
# Sets $stdout.sync
|
19
26
|
def run
|
20
27
|
queue_name = @config.queue_name
|
21
28
|
queue_url = resolve_queue queue_name
|
29
|
+
function_name = @config.invoke_lambda
|
22
30
|
|
23
31
|
send_to_url = if @config.send_to
|
24
32
|
resolve_queue @config.send_to
|
@@ -78,6 +86,18 @@ module SqsGrep
|
|
78
86
|
end
|
79
87
|
end
|
80
88
|
|
89
|
+
if function_name
|
90
|
+
send_res = @config.lambda_client.invoke(
|
91
|
+
function_name: function_name,
|
92
|
+
invocation_type: 'Event',
|
93
|
+
payload: m.body
|
94
|
+
)
|
95
|
+
if !@config.json_format
|
96
|
+
p send_res
|
97
|
+
puts ""
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
81
101
|
if @config.delete_matched
|
82
102
|
delete_res = @config.sqs_client.delete_message(
|
83
103
|
queue_url: queue_url,
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rachel Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|