fluent-plugin-gimbal-tranquility 0.4.0.t11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 604da0c7db75be4e1f5ebc07d39eb03e4cfaec49
4
+ data.tar.gz: 8d6d28e3a9205701a75fe0ff1cd4eddd939586cd
5
+ SHA512:
6
+ metadata.gz: 4873601e278d0be258769dfe57b597d9e5fad51e51620e890b39561247afe94e861ad22072d6db690df57a973d60576eb45124388b7b712157cdc5593672e3bc
7
+ data.tar.gz: dc59864a56c371885f06f43e2892da1b5a561d75f9a65d9e9c48512484d21884d14b873e5ba43222dd08bfc75f7bf6ab7e554c2d37eaf1a6cdaa6f963eb168cf
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,27 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+
4
+ Metrics/MethodLength:
5
+ CountComments: false
6
+ Max: 25
7
+
8
+ Metrics/AbcSize:
9
+ Max: 25
10
+
11
+ Style/Semicolon:
12
+ AllowAsExpressionSeparator: true
13
+
14
+ Style/EachWithObject:
15
+ Enabled: false
16
+
17
+ Style/FrozenStringLiteralComment:
18
+ Enabled: false
19
+
20
+ Documentation:
21
+ Enabled: false
22
+
23
+ Style/ExtraSpacing:
24
+ Enabled: false
25
+
26
+ AllCops:
27
+ TargetRubyVersion: 2.3
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ # Change Log
2
+
3
+ ## [0.4.0] - 2019-03-15
4
+ ### Change
5
+ - Rename plugin
6
+
7
+ ## [0.3.1] - 2016-11-15
8
+ ### Fix
9
+ - Locks gem versions
10
+
11
+ ## [0.3.0] - 2016-09-23
12
+ ### Add
13
+ - Higher push timeouts
14
+ - Async push
15
+
16
+ ## [0.2.3] - 2016-09-22
17
+ ### Fix
18
+ - Fix Plugin initialization
19
+
20
+ ## [0.2.2] - 2016-09-22
21
+ ### Fix
22
+ - Fix retry exceptions
23
+
24
+ ## [0.2.1] - 2016-09-22
25
+ ### Fix
26
+ - Retry methods and exceptions
27
+
28
+ ## [0.2.0] - 2016-09-22
29
+ ### Add
30
+ - Retry configuration
31
+
32
+ ## [0.1.3] - 2016-09-21
33
+ ### Fix
34
+ - Removed GZIP content encoding
35
+
36
+ ## [0.1.2] - 2016-09-21
37
+ ### Fix
38
+ - Added the `net-http-persistent` gem dependency
39
+
40
+ ## [0.1.1] - 2016-09-21
41
+ ### Fix
42
+ - Plugin Entry point
43
+
44
+ ## [0.1.0] - 2016-09-19
45
+ ### Add
46
+ - Single-point dataset pushing to a Tranquility backend
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at marcelo.wiermann@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-tranquility.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Marcelo Wiermann
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Fluent::Tranquility
2
+
3
+ This is a plugin to allow pushing messages to a Druid Tranquility HTTP Backend.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'fluent/tranquility'
5
+ require 'pry'
6
+
7
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fluent/tranquility/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'fluent-plugin-gimbal-tranquility'
8
+ spec.version = Fluent::Tranquility::VERSION
9
+ spec.authors = ['Marcelo Wiermann']
10
+ spec.email = ['marcelo.wiermann@gmail.com']
11
+ spec.summary = 'Druid Tranquility Fluentd Output Plugin'
12
+ spec.description = 'Druid Tranquility Fluentd Output Plugin'
13
+ spec.license = 'MIT'
14
+ spec.bindir = 'exe'
15
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
+ spec.require_paths = ['lib']
17
+ spec.files = `git ls-files -z`
18
+ .split("\x0")
19
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+
21
+ # spec.add_runtime_dependency 'faraday', '~> 0.10'
22
+ # spec.add_runtime_dependency 'fluentd', '~> 0.12'
23
+ # spec.add_runtime_dependency 'net-http-persistent', ['>= 2.9', '< 3']
24
+
25
+ spec.add_runtime_dependency "fluentd", [">= 0.14.15", "< 2"]
26
+ spec.add_runtime_dependency "faraday", "0.15.4"
27
+ spec.add_runtime_dependency "net-http-persistent", "2.9.4"
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.12'
30
+ spec.add_development_dependency 'rake', '~> 10.0'
31
+ spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'test-unit'
33
+ spec.add_development_dependency 'rspec-mocks'
34
+ spec.add_development_dependency 'rubocop'
35
+ spec.add_development_dependency 'pry'
36
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path('../../tranquility', __FILE__)
@@ -0,0 +1,14 @@
1
+ require 'bundler/setup'
2
+ require 'fluent/output'
3
+
4
+ module Fluent
5
+ module Tranquility
6
+ autoload :PusherFactory, File.expand_path('../tranquility/pusher_factory', __FILE__)
7
+ autoload :Pusher, File.expand_path('../tranquility/pusher', __FILE__)
8
+ autoload :Writer, File.expand_path('../tranquility/writer', __FILE__)
9
+ autoload :Formatter, File.expand_path('../tranquility/formatter', __FILE__)
10
+
11
+ require File.expand_path('../tranquility/plugin', __FILE__)
12
+ Fluent::Plugin.register_output('tranquility', Plugin)
13
+ end
14
+ end
@@ -0,0 +1,41 @@
1
+ module Fluent
2
+ module Tranquility
3
+ class Formatter
4
+ def call(_tag, _time, record)
5
+ begin
6
+ record.to_json + "\n"
7
+ rescue Encoding::UndefinedConversionError => exc
8
+ # record.force_encoding("ASCII-8BIT").encode('UTF-8').to_json
9
+ puts
10
+ puts "@@@@@@"
11
+ puts "Exc: #{exc.message}"
12
+ puts "Error: #{exc.message}\nRec: #{record}\nFixing..."
13
+ # record.encode('UTF-8', 'UTF-8').to_json + "\n"
14
+
15
+
16
+ record.each do |k, v|
17
+ # record[k] = v.encode('UTF-8', 'UTF-8')
18
+ record[k] = v.encode!(Encoding::UTF_8)
19
+
20
+ # if (v.respond_to?(:to_utf8))
21
+ # [ k, v.to_utf8 ]
22
+ # elsif (v.respond_to?(:encoding))
23
+ # [ k, v.dup.encode('UTF-8') ]
24
+ # else
25
+ # [ k, v ]
26
+ # end
27
+
28
+ # record[k] = v.encode('UTF-8', invalid: :replace, )
29
+
30
+ end
31
+
32
+ puts "Fixed: #{record}"
33
+ puts "@@@@@@"
34
+ puts
35
+
36
+ return record.to_json + "\n"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,40 @@
1
+ require 'forwardable'
2
+ require 'faraday'
3
+ require 'time'
4
+
5
+ module Fluent
6
+ module Tranquility
7
+ class Plugin < BufferedOutput
8
+ extend Forwardable
9
+
10
+ desc 'Tranquility URL'
11
+ config_param :url, :string
12
+
13
+ desc 'Druid Dataset'
14
+ config_param :dataset, :string
15
+
16
+ config_section :retries, multi: false, init: true do
17
+ config_param :max, :integer, default: 5
18
+ config_param :interval, :float, default: 1
19
+ config_param :interval_randomness, :float, default: 0.5
20
+ config_param :backoff_factor, :float, default: 2
21
+ end
22
+
23
+ def start
24
+ super
25
+ @writer = Writer.new.tap do |w|
26
+ w.pusher = PusherFactory.call(url: @url, dataset: @dataset, retries: @retries.to_h)
27
+ end
28
+
29
+ @formatter = Formatter.new
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :writer, :formatter
35
+
36
+ def_delegator :writer, :call, :write
37
+ def_delegator :formatter, :call, :format
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,28 @@
1
+ module Fluent
2
+ module Tranquility
3
+ class Pusher
4
+ attr_accessor :connection
5
+
6
+ def initialize(connection, dataset)
7
+ @connection = connection
8
+ @dataset = dataset
9
+ end
10
+
11
+ def call(data)
12
+ res = connection.post("/v1/post/#{dataset}") do |req|
13
+ req.headers['Content-Type'] = 'text/plain'
14
+ req.body = data
15
+ req.params['async'] = true
16
+ req.options.timeout = 60
17
+ req.options.open_timeout = 60
18
+ end
19
+
20
+ res.success?
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :dataset
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,34 @@
1
+ module Fluent
2
+ module Tranquility
3
+ class PusherFactory
4
+ EXCEPTIONS = %w(Errno::ETIMEDOUT
5
+ Faraday::TimeoutError
6
+ Faraday::Error::TimeoutError
7
+ Net::ReadTimeout).freeze
8
+
9
+ def self.call(*args)
10
+ new.call(*args)
11
+ end
12
+
13
+ def call(params = {})
14
+ connection = connection_for(params[:url], params[:retries])
15
+ Pusher.new(connection, params[:dataset])
16
+ end
17
+
18
+ private
19
+
20
+ def connection_for(url, options = {})
21
+ Faraday.new(url: url) do |f|
22
+ f.request :retry, max: options.fetch(:max, 5),
23
+ interval: options.fetch(:interval, 1),
24
+ interval_randomness: options.fetch(:interval_randomness, 0.5),
25
+ backoff_factor: options.fetch(:backoff_factor, 2),
26
+ methods: %w(post),
27
+ exceptions: EXCEPTIONS
28
+
29
+ f.adapter :net_http_persistent
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ module Fluent
2
+ module Tranquility
3
+ VERSION = '0.4.0.t11'.freeze
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module Fluent
2
+ module Tranquility
3
+ class Writer
4
+ attr_accessor :pusher
5
+
6
+ def call(chunk)
7
+ pusher.call(chunk.read)
8
+ end
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-gimbal-tranquility
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0.t11
5
+ platform: ruby
6
+ authors:
7
+ - Marcelo Wiermann
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.15
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.14.15
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: faraday
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '='
38
+ - !ruby/object:Gem::Version
39
+ version: 0.15.4
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 0.15.4
47
+ - !ruby/object:Gem::Dependency
48
+ name: net-http-persistent
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 2.9.4
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '='
59
+ - !ruby/object:Gem::Version
60
+ version: 2.9.4
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.12'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.12'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '10.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '10.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rspec
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '3.0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: test-unit
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rspec-mocks
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rubocop
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: pry
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ description: Druid Tranquility Fluentd Output Plugin
160
+ email:
161
+ - marcelo.wiermann@gmail.com
162
+ executables: []
163
+ extensions: []
164
+ extra_rdoc_files: []
165
+ files:
166
+ - ".gitignore"
167
+ - ".rspec"
168
+ - ".rubocop.yml"
169
+ - ".travis.yml"
170
+ - CHANGELOG.md
171
+ - CODE_OF_CONDUCT.md
172
+ - Gemfile
173
+ - LICENSE.txt
174
+ - README.md
175
+ - Rakefile
176
+ - bin/console
177
+ - bin/setup
178
+ - fluent-plugin-gimbal-tranquility.gemspec
179
+ - lib/fluent/plugin/out_tranquility.rb
180
+ - lib/fluent/tranquility.rb
181
+ - lib/fluent/tranquility/formatter.rb
182
+ - lib/fluent/tranquility/plugin.rb
183
+ - lib/fluent/tranquility/pusher.rb
184
+ - lib/fluent/tranquility/pusher_factory.rb
185
+ - lib/fluent/tranquility/version.rb
186
+ - lib/fluent/tranquility/writer.rb
187
+ homepage:
188
+ licenses:
189
+ - MIT
190
+ metadata: {}
191
+ post_install_message:
192
+ rdoc_options: []
193
+ require_paths:
194
+ - lib
195
+ required_ruby_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">"
203
+ - !ruby/object:Gem::Version
204
+ version: 1.3.1
205
+ requirements: []
206
+ rubyforge_project:
207
+ rubygems_version: 2.5.1
208
+ signing_key:
209
+ specification_version: 4
210
+ summary: Druid Tranquility Fluentd Output Plugin
211
+ test_files: []