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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58de437281552a856142c2f162e1e5f41156d291729d3073a7a9593ac7b5dcae
4
- data.tar.gz: 3fefede13a54aa7a94c115ccd228581e522a450bcaea84f442987381ebe2da3c
3
+ metadata.gz: dfabc562e28074e3dc85947047d7dd251abe00839bfaab16a60beaf563024ec0
4
+ data.tar.gz: 49abb2fc2e1e7a8a206ac882702a8907a316b1de77ddc5ac8e4188ac166280f9
5
5
  SHA512:
6
- metadata.gz: 1bdb63e13368f1e81a1a64b4706594eb7668a527b12538f9950b3a4301158007b6830d3e8899b21e93db3dadfed192eeac8b5d0ac902076025139aa860e60e22
7
- data.tar.gz: 0d11fe9ca5573486795e19ae4b6c95a9c51d441c5c8fd9a15b15cb55bc6612bc8113797cdcce9d9b07150e548887876b4fd7aaf8a30a181c28d32e749390618d
6
+ metadata.gz: 77ab05bc4c6a6491f1f98e2355b283889590cd93ee64043d56605961a2da8a6a1396f7cc36308fd6afee8ef1d80bd6cd15fab610c4e18c555f5bc9a643c64cb6
7
+ data.tar.gz: 82a5193f904ef00ced6a7758de7d1cd6381b6624a117fa237379a06e755eaf5a44167d9ee3611d85830e39f1934a5f75c6b868cd8ae2dca0a14fe7a00e97471d
@@ -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
@@ -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
@@ -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,
@@ -1,4 +1,4 @@
1
1
  module SqsGrep
2
- VERSION = '0.1.2'
3
- DATE = '2018-02-25'
2
+ VERSION = '0.1.3'
3
+ DATE = '2018-09-03'
4
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.2
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-02-25 00:00:00.000000000 Z
11
+ date: 2018-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk