fluent-plugin-nsq 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 +15 -0
- data/fluent-plugin-nsq.gemspec +23 -0
- data/lib/fluent/plugin/out_nsq.rb +52 -0
- data/test/helper.rb +1 -0
- data/test/plugin/test_out_nsq.rb +49 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Y2M1NDBmNjFmOGY5ZjkyMTM4MTdkMDAwYmY0Y2U2OGMzZGJmNDZkZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OGZlMzMyZmQ3N2ZjZjk2NzJiODdhODBkNGEzNjJkMTMzYTM0M2YwMw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWIzNDZkZDViMzBkYjUzYWM5MzZkNDMyYzAyYzA2MDY5MTIwN2M0OGJhZDFh
|
10
|
+
NjdjMTFjZjYwNGYwMzRiNjY0MDlhNDkzN2U0OTRlOTgyMzNhZTQ0OGM0ZDVl
|
11
|
+
YjFkOWZjNmUxNzc3YmViYjBkZjliNWE3MjcxYTc4M2Y2NjA4OGE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MTc4ZjA4MTMxOWI3ZDk4OTE0MWUyYzk4ZjQ1ZDg2N2Y4NTM4NGU4OThjNTQ0
|
14
|
+
MWQzY2U2Nzc2ZTE2MTAzZDBlNzA5NDAxNWZiZDY1ZTg1MTlmOGEzZTdhNDNj
|
15
|
+
NTI5NjIwODRkN2E5NmZhOGY4NjE5OTg4MzY2YzI3MmIyNWZkOWY=
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "fluent-plugin-nsq"
|
5
|
+
s.version = `cat VERSION`
|
6
|
+
s.authors = ["lxfontes", "dterror"]
|
7
|
+
s.email = ["lucas@uken.com", "diogo@uken.com"]
|
8
|
+
s.description = %q{NSQ output plugin for Fluentd}
|
9
|
+
s.summary = %q{output plugin for fluentd}
|
10
|
+
s.homepage = "https://github.com/uken/fluent-plugin-nsq"
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
git_files = `git ls-files`.split($/)
|
14
|
+
|
15
|
+
s.files = git_files.grep(%r{^(lib|fluent|bin)})
|
16
|
+
s.executables = git_files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
s.test_files = git_files.grep(%r{^(test|spec|features)/})
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_runtime_dependency 'fluentd', '~> 0.10'
|
21
|
+
s.add_runtime_dependency 'nsq-ruby', '~> 1.0'
|
22
|
+
s.add_development_dependency 'rake', '~> 10'
|
23
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'nsq'
|
3
|
+
|
4
|
+
module Fluent
|
5
|
+
class NSQOutput < BufferedOutput
|
6
|
+
Plugin.register_output('nsq', self)
|
7
|
+
|
8
|
+
config_param :topic, :string, default: nil
|
9
|
+
config_param :nsqlookupd, :string, default: nil
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure(conf)
|
16
|
+
super
|
17
|
+
|
18
|
+
raise ConfigError, "Missing nsqlookupd" unless @nsqlookupd
|
19
|
+
raise ConfigError, "Missing topic" unless @topic
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
23
|
+
lookupds = @nsqlookupd.split(',')
|
24
|
+
@producer = Nsq::Producer.new(
|
25
|
+
nslookupd: lookupds,
|
26
|
+
topic: @topic
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def shutdown
|
31
|
+
@producer.terminate
|
32
|
+
end
|
33
|
+
|
34
|
+
def format(tag, time, record)
|
35
|
+
[tag, time, record].to_msgpack
|
36
|
+
end
|
37
|
+
|
38
|
+
def write(chunk)
|
39
|
+
return if chunk.empty?
|
40
|
+
|
41
|
+
chunk.msgpack_each do |tag, time, record|
|
42
|
+
next unless record.is_a? Hash
|
43
|
+
#TODO get rid of this extra copy
|
44
|
+
tagged_record = record.merge(
|
45
|
+
_key: tag,
|
46
|
+
_ts: time
|
47
|
+
)
|
48
|
+
@producer.write(tagged_record.to_json)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'minitest/pride'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'fluent/test'
|
4
|
+
require 'fluent/plugin/out_nsq'
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
$:.push File.expand_path("../lib", __FILE__)
|
11
|
+
$:.push File.dirname(__FILE__)
|
12
|
+
|
13
|
+
class TestNSQOutput < Test::Unit::TestCase
|
14
|
+
TCONFIG = %[
|
15
|
+
nsqlookupd localhost:4161
|
16
|
+
topic logs
|
17
|
+
]
|
18
|
+
def setup
|
19
|
+
#Nsq.logger = Logger.new(STDOUT)
|
20
|
+
Fluent::Test.setup
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_configure
|
24
|
+
d = create_driver
|
25
|
+
assert_not_nil d.instance.topic
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_driver(tag='test', conf=TCONFIG)
|
29
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::NSQOutput, tag).configure(conf, true)
|
30
|
+
end
|
31
|
+
|
32
|
+
def sample_record
|
33
|
+
{'age' => 26, 'request_id' => '42', 'parent_id' => 'parent', 'sub' => {'field'=>{'pos'=>15}}}
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_wrong_config
|
37
|
+
assert_raise Fluent::ConfigError do
|
38
|
+
d = create_driver('test','')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_sample_record_loop
|
43
|
+
d = create_driver
|
44
|
+
100.times.each do |t|
|
45
|
+
d.emit(sample_record)
|
46
|
+
end
|
47
|
+
d.run
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-nsq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lxfontes
|
8
|
+
- dterror
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-11-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.10'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.10'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: nsq-ruby
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ~>
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10'
|
56
|
+
description: NSQ output plugin for Fluentd
|
57
|
+
email:
|
58
|
+
- lucas@uken.com
|
59
|
+
- diogo@uken.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- fluent-plugin-nsq.gemspec
|
65
|
+
- lib/fluent/plugin/out_nsq.rb
|
66
|
+
- test/helper.rb
|
67
|
+
- test/plugin/test_out_nsq.rb
|
68
|
+
homepage: https://github.com/uken/fluent-plugin-nsq
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.3.0
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: output plugin for fluentd
|
92
|
+
test_files:
|
93
|
+
- test/helper.rb
|
94
|
+
- test/plugin/test_out_nsq.rb
|