async-fluent-azure-eventhubs-plugin 0.0.1
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 +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +28 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/Rakefile +8 -0
- data/aync-fluent-plugin-azureeventhubs.gemspec +21 -0
- data/lib/fluent/plugin/azureeventhubs/http.rb +67 -0
- data/lib/fluent/plugin/out_azureeventhubs_buffered.rb +61 -0
- data/test/helper.rb +26 -0
- data/test/plugin/test_out_azure_event_hub.rb +28 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6ef121f2e386234907016780997478329045c40e756f62f4b5c730d905ba1052
|
4
|
+
data.tar.gz: a713a0981edfee6961bb20a8718fa0210ec55d3448185fd70c63cd683b74698e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9c38dfe625801d2f3b8809d820d2a50eac8dd8a50ff7561d38d84196c4da9c158e1675fa0f47e7679e1526f96f16b1324e4f9c2e4c3c17588e8035a2a81d38ae
|
7
|
+
data.tar.gz: a8e5093ef6261b49c37a70d969ee3f59f32c148b5bab1cea09d686e9a6d957387bb4d20bbe3445e22d2dab70cc79346fcac0f96a2ba69541824b2ce8946d592b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3.1
|
7
|
+
- 2.4.1
|
8
|
+
- 2.5.0
|
9
|
+
- ruby-head
|
10
|
+
|
11
|
+
before_install:
|
12
|
+
- gem update --system
|
13
|
+
|
14
|
+
script:
|
15
|
+
- bundle exec rake test
|
16
|
+
|
17
|
+
sudo: false
|
18
|
+
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: ruby-head
|
22
|
+
deploy:
|
23
|
+
provider: rubygems
|
24
|
+
api_key: "bc5cc687adff822e861d4df96c0986e4"
|
25
|
+
gemspec: aync-fluent-plugin-azureeventhubs.gemspec
|
26
|
+
on:
|
27
|
+
tags: true
|
28
|
+
all_branches: true
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 sio2k
|
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.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Sandeep Kotha"]
|
5
|
+
gem.email = ["sandeep.kotha@live.com"]
|
6
|
+
gem.summary = "Fluentd output plugin for Azure Event Hubs"
|
7
|
+
gem.description = "Fluentd output plugin for Azure Event Hubs"
|
8
|
+
gem.homepage = "https://github.com/sio2k/async-fluent-plugin-azureeventhubs-"
|
9
|
+
gem.license = "MIT"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.name = "async-fluent-azure-eventhubs-plugin"
|
16
|
+
gem.version = "0.0.1"
|
17
|
+
|
18
|
+
gem.add_development_dependency "rake", ">= 0.9.2"
|
19
|
+
gem.add_dependency "fluentd", [">= 0.10.58", "< 2"]
|
20
|
+
gem.add_development_dependency "test-unit", ">= 3.0.8"
|
21
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
|
2
|
+
class AzureEventHubsHttpSender
|
3
|
+
def initialize(connection_string, hub_name, expiry=3600,proxy_addr='',proxy_port=3128,open_timeout=60,read_timeout=60)
|
4
|
+
require 'openssl'
|
5
|
+
require 'base64'
|
6
|
+
require 'unirest'
|
7
|
+
require 'json'
|
8
|
+
require 'cgi'
|
9
|
+
require 'time'
|
10
|
+
@connection_string = connection_string
|
11
|
+
@hub_name = hub_name
|
12
|
+
@expiry_interval = expiry
|
13
|
+
@proxy_addr = proxy_addr
|
14
|
+
@proxy_port = proxy_port
|
15
|
+
@open_timeout = open_timeout
|
16
|
+
@read_timeout = read_timeout
|
17
|
+
|
18
|
+
if @connection_string.count(';') != 2
|
19
|
+
raise "Connection String format is not correct"
|
20
|
+
end
|
21
|
+
|
22
|
+
@connection_string.split(';').each do |part|
|
23
|
+
if ( part.index('Endpoint') == 0 )
|
24
|
+
@endpoint = 'https' + part[11..-1]
|
25
|
+
elsif ( part.index('SharedAccessKeyName') == 0 )
|
26
|
+
@sas_key_name = part[20..-1]
|
27
|
+
elsif ( part.index('SharedAccessKey') == 0 )
|
28
|
+
@sas_key_value = part[16..-1]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
@uri = URI.parse("#{@endpoint}#{@hub_name}/messages")
|
32
|
+
end
|
33
|
+
|
34
|
+
def generate_sas_token(uri)
|
35
|
+
target_uri = CGI.escape(uri.downcase).downcase
|
36
|
+
expiry = Time.now.to_i + @expiry_interval
|
37
|
+
to_sign = "#{target_uri}\n#{expiry}";
|
38
|
+
signature = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), @sas_key_value, to_sign)).strip())
|
39
|
+
|
40
|
+
token = "SharedAccessSignature sr=#{target_uri}&sig=#{signature}&se=#{expiry}&skn=#{@sas_key_name}"
|
41
|
+
return token
|
42
|
+
end
|
43
|
+
|
44
|
+
private :generate_sas_token
|
45
|
+
|
46
|
+
def send(payload)
|
47
|
+
send_w_properties(payload, nil)
|
48
|
+
end
|
49
|
+
|
50
|
+
def send_w_properties(payload, properties)
|
51
|
+
token = generate_sas_token(@uri.to_s)
|
52
|
+
headers = {
|
53
|
+
'Content-Type' => 'application/atom+xml;type=entry;charset=utf-8',
|
54
|
+
'Authorization' => token
|
55
|
+
}
|
56
|
+
if not properties.nil?
|
57
|
+
headers = headers.merge(properties)
|
58
|
+
end
|
59
|
+
Unirest.post @uri.request_uri,
|
60
|
+
headers:{ 'Content-Type' => 'application/atom+xml;type=entry;charset=utf-8',
|
61
|
+
'Authorization' => token
|
62
|
+
},
|
63
|
+
parameters:payload {|response|
|
64
|
+
response.code
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Fluent::AzureEventHubsOutputBuffered < Fluent::BufferedOutput
|
2
|
+
Fluent::Plugin.register_output('azure_eventhub_buffered', self)
|
3
|
+
|
4
|
+
helpers :compat_parameters, :inject
|
5
|
+
|
6
|
+
DEFAULT_BUFFER_TYPE = "memory"
|
7
|
+
|
8
|
+
config_param :connection_string, :string
|
9
|
+
config_param :hub_name, :string
|
10
|
+
config_param :include_tag, :bool, :default => false
|
11
|
+
config_param :include_time, :bool, :default => false
|
12
|
+
config_param :tag_time_name, :string, :default => 'time'
|
13
|
+
config_param :expiry_interval, :integer, :default => 3600 # 60min
|
14
|
+
config_param :type, :string, :default => 'https' # https / amqps (Not Implemented)
|
15
|
+
config_param :proxy_addr, :string, :default => ''
|
16
|
+
config_param :proxy_port, :integer,:default => 3128
|
17
|
+
config_param :open_timeout, :integer,:default => 60
|
18
|
+
config_param :read_timeout, :integer,:default => 60
|
19
|
+
config_param :message_properties, :hash, :default => nil
|
20
|
+
|
21
|
+
config_section :buffer do
|
22
|
+
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
23
|
+
config_set_default :chunk_keys, ['tag']
|
24
|
+
end
|
25
|
+
|
26
|
+
def configure(conf)
|
27
|
+
compat_parameters_convert(conf, :buffer, :inject)
|
28
|
+
super
|
29
|
+
case @type
|
30
|
+
when 'amqps'
|
31
|
+
raise NotImplementedError
|
32
|
+
else
|
33
|
+
require_relative 'azureeventhubs/http'
|
34
|
+
@sender = AzureEventHubsHttpSender.new(@connection_string, @hub_name, @expiry_interval,@proxy_addr,@proxy_port,@open_timeout,@read_timeout)
|
35
|
+
end
|
36
|
+
raise Fluent::ConfigError, "'tag' in chunk_keys is required." if not @chunk_key_tag
|
37
|
+
end
|
38
|
+
|
39
|
+
def format(tag, time, record)
|
40
|
+
record = inject_values_to_record(tag, time, record)
|
41
|
+
[tag, time, record].to_msgpack
|
42
|
+
end
|
43
|
+
|
44
|
+
def formatted_to_msgpack_binary?
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def write(chunk)
|
49
|
+
chunk.msgpack_each { |tag, time, record|
|
50
|
+
p record.to_s
|
51
|
+
if @include_tag
|
52
|
+
record['tag'] = tag
|
53
|
+
end
|
54
|
+
if @include_time
|
55
|
+
record[@tag_time_name] = time
|
56
|
+
end
|
57
|
+
@sender.send_w_properties(record, @message_properties)
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
13
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
|
+
require 'fluent/test'
|
15
|
+
unless ENV.has_key?('VERBOSE')
|
16
|
+
nulllogger = Object.new
|
17
|
+
nulllogger.instance_eval {|obj|
|
18
|
+
def method_missing(method, *args)
|
19
|
+
end
|
20
|
+
}
|
21
|
+
$log = nulllogger
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
class Test::Unit::TestCase
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'fluent/output'
|
3
|
+
|
4
|
+
class AzureEventHubTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Fluent::Test.setup
|
7
|
+
end
|
8
|
+
|
9
|
+
BASE_CONFIG = %[
|
10
|
+
type azure_eventhub_buffered
|
11
|
+
]
|
12
|
+
|
13
|
+
CONFIG = BASE_CONFIG + %[
|
14
|
+
connection_string sb://sample
|
15
|
+
]
|
16
|
+
|
17
|
+
def create_driver(conf = CONFIG, tag='test')
|
18
|
+
"sample"
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def test_format
|
24
|
+
d = create_driver
|
25
|
+
assert_equal 'sample', d
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: async-fluent-azure-eventhubs-plugin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sandeep Kotha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.2
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fluentd
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.58
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.10.58
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: test-unit
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.0.8
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 3.0.8
|
61
|
+
description: Fluentd output plugin for Azure Event Hubs
|
62
|
+
email:
|
63
|
+
- sandeep.kotha@live.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- ".travis.yml"
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- aync-fluent-plugin-azureeventhubs.gemspec
|
75
|
+
- lib/fluent/plugin/azureeventhubs/http.rb
|
76
|
+
- lib/fluent/plugin/out_azureeventhubs_buffered.rb
|
77
|
+
- test/helper.rb
|
78
|
+
- test/plugin/test_out_azure_event_hub.rb
|
79
|
+
homepage: https://github.com/sio2k/async-fluent-plugin-azureeventhubs-
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.7.7
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Fluentd output plugin for Azure Event Hubs
|
103
|
+
test_files:
|
104
|
+
- test/helper.rb
|
105
|
+
- test/plugin/test_out_azure_event_hub.rb
|