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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 442969f48ef362b5ab9506ad2869e865374b4b43
4
- data.tar.gz: 44618c26a724d729b7544a1493adad7b2b63a308
3
+ metadata.gz: beec074fa413a6c39d5f9dca6200eb4e31b08f7c
4
+ data.tar.gz: 7ce95fdc118df30ea71050d45c0e54c4e74a2df1
5
5
  SHA512:
6
- metadata.gz: 5d74298b7f7383e87303a5a48205dd71708d3429c7eae222bd74097866cbf8432f0babee2a5c4409581b6655f08b6ea15b13fa9dab2dba9a56a4d7365f294264
7
- data.tar.gz: 91c311d76ad18fc3fcd7a9dcd98cdc52e9cf17c9f8a3d29f0c0671b7cfc874918f6d147b1a66af53117f60773b61c4357c418bebb03a9a35cf8cdc13b7a108d4
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
 
@@ -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.1.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
- get_or_create_exchange.publish Yajl.dump(event), routing_key: tag, content_type: @content_type
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
 
@@ -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.1.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: 2015-09-01 00:00:00.000000000 Z
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.2.2
138
+ rubygems_version: 2.5.2
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: AMQP output plugin for Fluent