fluent-plugin-amqp2 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/fluent-plugin-amqp2.gemspec +1 -1
- data/lib/fluent/plugin/out_amqp.rb +6 -1
- data/test/out_amqp.rb +44 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beec074fa413a6c39d5f9dca6200eb4e31b08f7c
|
4
|
+
data.tar.gz: 7ce95fdc118df30ea71050d45c0e54c4e74a2df1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 771df5ba0f7fc2706d2c3fe08a63e55ce87f9da1df344ca39950965a6ad8c06bbfd4353542c6da4611dd3ff4019936839d5080b3afb7848a6d33f76e8fb51d45
|
7
|
+
data.tar.gz: ed0095bf9f82cfa2462a1d0186697f6daaaadc3b51b03caa90cc7848a2cf2b485c5d282c288838d3adf577a27b357be8583ec6b4c55214beb17fa8fd7c11c369
|
data/README.md
CHANGED
@@ -43,6 +43,7 @@ Or install it yourself as:
|
|
43
43
|
exchange_durable true # optionally set exchange durability - default is true.
|
44
44
|
payload_only false # optional - default is false. if true, only the payload will be sent. if false, data format is { "key" => tag, "timestamp" => time, "payload" => record }.
|
45
45
|
content_type application/octet-stream # optional - default is application/octet-stream. some amqp consumers will expect application/json.
|
46
|
+
priority 0 # the priority for the message - requires bunny >= 1.1.6 and rabbitmq >= 3.5
|
46
47
|
</match>
|
47
48
|
```
|
48
49
|
|
data/fluent-plugin-amqp2.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "fluent-plugin-amqp2"
|
7
|
-
gem.version = "0.
|
7
|
+
gem.version = "0.2.0"
|
8
8
|
gem.authors = ["Augusto Becciu", "Juan Manuel Barreneche"]
|
9
9
|
gem.email = ["devs@restorando.com"]
|
10
10
|
|
@@ -15,6 +15,7 @@ class AmqpOutput < Fluent::BufferedOutput
|
|
15
15
|
config_param :exchange_durable, :bool, default: true
|
16
16
|
config_param :payload_only, :bool, default: false
|
17
17
|
config_param :content_type, :string, default: "application/octet-stream"
|
18
|
+
config_param :priority, :integer, default: nil
|
18
19
|
|
19
20
|
def initialize(*)
|
20
21
|
super
|
@@ -66,7 +67,11 @@ class AmqpOutput < Fluent::BufferedOutput
|
|
66
67
|
def write(chunk)
|
67
68
|
chunk.msgpack_each do |(tag, time, record)|
|
68
69
|
event = @payload_only ? record : { "key" => tag, "timestamp" => time, "payload" => record }
|
69
|
-
|
70
|
+
puboptions = { routing_key: tag, content_type: @content_type }
|
71
|
+
if @priority
|
72
|
+
puboptions[:priority] = @priority
|
73
|
+
end
|
74
|
+
get_or_create_exchange.publish Yajl.dump(event), puboptions
|
70
75
|
end
|
71
76
|
end
|
72
77
|
|
data/test/out_amqp.rb
CHANGED
@@ -23,6 +23,18 @@ class AmqpOutputTest < Test::Unit::TestCase
|
|
23
23
|
buffert_type memory
|
24
24
|
]
|
25
25
|
|
26
|
+
PRIORITYCONFIG = %[
|
27
|
+
host localhost
|
28
|
+
port 3333
|
29
|
+
user test
|
30
|
+
password test
|
31
|
+
vhost /test
|
32
|
+
exchange test-exchange
|
33
|
+
exchange_type topic
|
34
|
+
priority 3
|
35
|
+
buffert_type memory
|
36
|
+
]
|
37
|
+
|
26
38
|
def create_driver(conf = CONFIG)
|
27
39
|
Fluent::Test::BufferedOutputTestDriver.new(Fluent::AmqpOutput).configure(conf)
|
28
40
|
end
|
@@ -38,6 +50,18 @@ class AmqpOutputTest < Test::Unit::TestCase
|
|
38
50
|
assert_equal "topic", d.instance.exchange_type
|
39
51
|
end
|
40
52
|
|
53
|
+
def test_configure_with_priority
|
54
|
+
d = create_driver PRIORITYCONFIG
|
55
|
+
assert_equal "localhost", d.instance.host
|
56
|
+
assert_equal 3333, d.instance.port
|
57
|
+
assert_equal "test", d.instance.user
|
58
|
+
assert_equal "test", d.instance.password
|
59
|
+
assert_equal "/test", d.instance.vhost
|
60
|
+
assert_equal "test-exchange", d.instance.exchange
|
61
|
+
assert_equal "topic", d.instance.exchange_type
|
62
|
+
assert_equal 3, d.instance.priority
|
63
|
+
end
|
64
|
+
|
41
65
|
def test_start_and_shutdown
|
42
66
|
d = create_driver
|
43
67
|
|
@@ -81,5 +105,25 @@ class AmqpOutputTest < Test::Unit::TestCase
|
|
81
105
|
d.run
|
82
106
|
end
|
83
107
|
|
108
|
+
def test_flush_with_priority
|
109
|
+
d = create_driver PRIORITYCONFIG
|
110
|
+
|
111
|
+
amqp_conn_mock = mock()
|
112
|
+
amqp_exchange_mock = mock()
|
113
|
+
Bunny.stubs(:new).returns(amqp_conn_mock)
|
114
|
+
amqp_conn_mock.stubs(:open?).returns(true)
|
115
|
+
amqp_conn_mock.stubs(:create_channel)
|
116
|
+
amqp_conn_mock.stubs(:stop)
|
117
|
+
Bunny::Exchange.stubs(:new).returns(amqp_exchange_mock)
|
118
|
+
|
119
|
+
t = Time.now.to_i
|
120
|
+
d.emit({"a" => 1}, t)
|
121
|
+
|
122
|
+
ev1 = Yajl.dump({"key" => "test", "timestamp" => t, "payload" => {"a"=>1}})
|
123
|
+
amqp_exchange_mock.expects(:publish).with(ev1, { routing_key: "test", content_type: 'application/octet-stream', priority: 3 })
|
124
|
+
|
125
|
+
d.run
|
126
|
+
end
|
127
|
+
|
84
128
|
end
|
85
129
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-amqp2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Augusto Becciu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.5.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: AMQP output plugin for Fluent
|