fluent-plugin-sqs-poll 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 546e6db771fc22d674a53d9c72b1fa173fe11e4b
4
+ data.tar.gz: 45328baf2a51121d0a43a5b0f7103baeafe40de6
5
+ SHA512:
6
+ metadata.gz: 925a21d42c16a361ac28117996837d013722857ccb83358e256ae789093caf3106947c375cdbc6a681693a6fedace0e23f4cda9d0197473a3b4eec4ded4d1c03
7
+ data.tar.gz: 93807b7a6a40b3b3d7491fb246487a91b345480f33927fc0c6b8decf1efaf14365eed15ef5d643aba8519f802a814cff08b37019b0dd161ced5135280c82aa84
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Richard Li
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # fluent-plugin-sqs-poll
2
+ fluent input plugin poll data from AWS SQS
3
+
4
+ ## Install
5
+
6
+ ```bash
7
+ gem install fluent-plugin-sqs-poll
8
+ ```
9
+
10
+ ## Configuration
11
+
12
+ If either **aws_access_key** or **aws_secret_key** is missing, it will automatically
13
+ fall back to use IAM role for access control.
14
+
15
+ ```
16
+ <source>
17
+ type sqs_poll
18
+ aws_access_key {optional: your_aws_access_key}
19
+ aws_secret_key {optional: your_aws_secret_key}
20
+ tag {required: tag}
21
+ sqs_url {required: SQS_url}
22
+ max_number_of_messages {optional: # of messges poll at a time, default: 1}
23
+ </source>
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ When messages are pulled off SQS queue, it's stored in key **body** of the
29
+ emmitted output. If your SQS message is in a known format, you probably want to
30
+ use in conjunction with **fluent-plugin-parser**. For example, if your message
31
+ from SQS is in JSON format, then you would want to do:
32
+
33
+ ```
34
+ <source>
35
+ type sqs_poll
36
+ tag sqs.message
37
+ sqs_url https://sqs.us-east-1.amazonaws.com/123456789/some_queue
38
+ max_number_of_messages 10
39
+ </source>
40
+
41
+ <match sqs.message>
42
+ type parser
43
+ remove_prefix sqs
44
+ format json
45
+ key_name body
46
+ </match>
47
+ ```
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "fluent-plugin-sqs-poll"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Richard Li"]
5
+ spec.email = ["evilcat@wisewolfsolutions.com"]
6
+ spec.description = %q{fluent input plugin use aws-sdk v2 sqs poller to receive messages}
7
+ spec.summary = %q{fluent sqs poll input}
8
+ spec.homepage = "https://github.com/ecwws/fluent-plugin-sqs-poll"
9
+ spec.license = "MIT"
10
+
11
+ spec.files = `git ls-files`.split($/)
12
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
13
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_runtime_dependency "aws-sdk", '~> 2'
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.3"
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency "rspec", ">= 3.0.0"
21
+ end
@@ -0,0 +1,63 @@
1
+ module Fluent
2
+ require 'aws-sdk'
3
+
4
+ class SQSPollInput < Input
5
+ Fluent::Plugin.register_input('sqs_poll', self)
6
+
7
+ config_param :aws_access_key, :string, :default => nil, :secret => true
8
+ config_param :aws_secret_key, :string, :default => nil, :secret => true
9
+ config_param :tag, :string
10
+ config_param :sqs_url, :string
11
+ config_param :max_number_of_messages, :integer, default: 1
12
+
13
+ def configure(conf)
14
+ super
15
+ end
16
+
17
+ def start
18
+ super
19
+
20
+ @terminate = false
21
+ @thread = Thread.new(&method(:poll))
22
+ end
23
+
24
+ def shutdown
25
+ super
26
+
27
+ @terminate = true
28
+ @thread.join
29
+ end
30
+
31
+ def poll
32
+ region = @sqs_url.split('.')[1]
33
+ Aws.config.update(region: region)
34
+
35
+ if @aws_access_key && @aws_secret_key
36
+ Aws.config.update(
37
+ credentials: Aws::Credentials.new(@aws_access_key, @aws_secret_key)
38
+ )
39
+ end
40
+
41
+ poller = Aws::SQS::QueuePoller.new(@sqs_url)
42
+
43
+ poller.poll(max_number_of_messages: @max_number_of_messages) do |messages|
44
+ throw :stop_polling if @terminate
45
+ messages.each do |msg|
46
+ begin
47
+ Engine.emit(@tag, Time.now.to_i,
48
+ {
49
+ 'body' => msg.body,
50
+ 'handle' => msg.receipt_handle,
51
+ 'id' => msg.message_id,
52
+ 'md5' => msg.md5_of_body,
53
+ }
54
+ )
55
+ rescue Exception => e
56
+ $log.error("SQS exception", error: e.to_s, error_class: e.class.to_s)
57
+ $log.warn_backtrace(e.backtrace)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-sqs-poll
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Richard Li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ description: fluent input plugin use aws-sdk v2 sqs poller to receive messages
70
+ email:
71
+ - evilcat@wisewolfsolutions.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - LICENSE
78
+ - README.md
79
+ - fluent-plugin-sqs-poll.gemspec
80
+ - lib/fluent/plugin/in_sqs_poll.rb
81
+ homepage: https://github.com/ecwws/fluent-plugin-sqs-poll
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.2.2
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: fluent sqs poll input
105
+ test_files: []
106
+ has_rdoc: