fluent-plugin-amqp 0.9.3 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b4afb9f6144c0448aefb570fbe50d47f8ad4845c
4
+ data.tar.gz: 9c07383eb91e5e825d12fb23a93b294245afb9c8
5
+ SHA512:
6
+ metadata.gz: dc9872fd8d8fef5e4f38bebacbf440a7b6b89568f4285592d09190d4ecdf40ec32f9f94606f6f273a7e6ca1b2737d53d0aafc237a9b5002c62f41da07e006ab7
7
+ data.tar.gz: 972dcc4296cc3e0c87245fde0763336a39e8e436237ec3f7930516e68ca0db9c13aa7e19714ef19549d8770192c595960737c242a0c13da38b759effcbd8d48c
@@ -1,73 +1,64 @@
1
1
  require 'time'
2
- require 'fluent/input'
3
- require 'fluent/parser'
2
+ require 'fluent/plugin/input'
3
+ require 'fluent/plugin/parser'
4
+ require 'bunny'
4
5
 
5
- module Fluent
6
+ module Fluent::Plugin
6
7
  ##
7
8
  # AMQPInput to be used as a Fluent SOURCE, reading messages from a RabbitMQ
8
9
  # message broker
9
10
  class AMQPInput < Input
10
11
  Fluent::Plugin.register_input('amqp', self)
11
12
 
12
- # Define `router` method of v0.12 to support v0.10.57 or earlier
13
- unless method_defined?(:router)
14
- define_method("router") { Engine }
15
- end
13
+ helpers :compat_parameters, :parser
16
14
 
17
15
  # Bunny connection handle
18
16
  # - Allows mocking for test purposes
19
17
  attr_accessor :connection
20
18
 
21
- config_param :tag, :string, :default => "hunter.amqp"
22
-
23
- config_param :host, :string, :default => nil
24
- config_param :hosts, :array, :default => nil
25
- config_param :user, :string, :default => "guest"
26
- config_param :pass, :string, :default => "guest", :secret => true
27
- config_param :vhost, :string, :default => "/"
28
- config_param :port, :integer, :default => 5672
29
- config_param :ssl, :bool, :default => false
30
- config_param :verify_ssl, :bool, :default => false
31
- config_param :heartbeat, :integer, :default => 60
32
- config_param :queue, :string, :default => nil
33
- config_param :durable, :bool, :default => false
34
- config_param :exclusive, :bool, :default => false
35
- config_param :auto_delete, :bool, :default => false
36
- config_param :passive, :bool, :default => false
37
- config_param :payload_format, :string, :default => "json"
38
- config_param :tag_key, :bool, :default => false
39
- config_param :tag_header, :string, :default => nil
40
- config_param :time_header, :string, :default => nil
41
- config_param :tls, :bool, :default => false
42
- config_param :tls_cert, :string, :default => nil
43
- config_param :tls_key, :string, :default => nil
44
- config_param :tls_ca_certificates, :array, :default => nil
45
- config_param :tls_verify_peer, :bool, :default => true
46
- config_param :bind_exchange, :bool, :default => false
47
- config_param :exchange, :string, :default => ""
48
- config_param :routing_key, :string, :default => "#" # The routing key used to bind queue to exchange - # = matches all, * matches section (tag.*.info)
49
-
50
-
51
-
52
- def initialize
53
- require 'bunny'
54
- super
55
- end
56
-
19
+ config_param :tag, :string, default: "hunter.amqp"
20
+
21
+ config_param :host, :string, default: nil
22
+ config_param :hosts, :array, default: nil
23
+ config_param :user, :string, default: "guest"
24
+ config_param :pass, :string, default: "guest", secret: true
25
+ config_param :vhost, :string, default: "/"
26
+ config_param :port, :integer, default: 5672
27
+ config_param :ssl, :bool, default: false
28
+ config_param :verify_ssl, :bool, default: false
29
+ config_param :heartbeat, :integer, default: 60
30
+ config_param :queue, :string, default: nil
31
+ config_param :durable, :bool, default: false
32
+ config_param :exclusive, :bool, default: false
33
+ config_param :auto_delete, :bool, default: false
34
+ config_param :passive, :bool, default: false
35
+ config_param :payload_format, :string, default: "json"
36
+ config_param :tag_key, :bool, default: false
37
+ config_param :tag_header, :string, default: nil
38
+ config_param :time_header, :string, default: nil
39
+ config_param :tls, :bool, default: false
40
+ config_param :tls_cert, :string, default: nil
41
+ config_param :tls_key, :string, default: nil
42
+ config_param :tls_ca_certificates, :array, default: nil
43
+ config_param :tls_verify_peer, :bool, default: true
44
+ config_param :bind_exchange, :bool, default: false
45
+ config_param :exchange, :string, default: ""
46
+ config_param :routing_key, :string, default: "#" # The routing key used to bind queue to exchange - # = matches all, * matches section (tag.*.info)
57
47
 
58
48
  def configure(conf)
59
49
  conf['format'] ||= conf['payload_format'] # legacy
50
+ compat_parameters_convert(conf, :parser)
60
51
 
61
52
  super
62
53
 
63
- parser = TextParser.new
64
- if parser.configure(conf, false)
65
- @parser = parser
54
+ parser_config = conf.elements('parse').first
55
+ if parser_config
56
+ @parser = parser_create(conf: parser_config)
66
57
  end
67
58
 
68
59
  @conf = conf
69
60
  unless (@host || @hosts) && @queue
70
- raise ConfigError, "'host(s)' and 'queue' must be all specified."
61
+ raise Fluent::ConfigError, "'host(s)' and 'queue' must be all specified."
71
62
  end
72
63
  check_tls_configuration
73
64
  end
@@ -78,11 +69,11 @@ module Fluent
78
69
  @connection = Bunny.new get_connection_options unless @connection
79
70
  @connection.start
80
71
  @channel = @connection.create_channel
81
- q = @channel.queue(@queue, :passive => @passive, :durable => @durable,
82
- :exclusive => @exclusive, :auto_delete => @auto_delete)
72
+ q = @channel.queue(@queue, passive: @passive, durable: @durable,
73
+ exclusive: @exclusive, auto_delete: @auto_delete)
83
74
  if @bind_exchange
84
75
  log.info "Binding #{@queue} to #{@exchange}, :routing_key => #{@routing_key}"
85
- q.bind(exchange=@exchange, :routing_key => @routing_key)
76
+ q.bind(exchange=@exchange, routing_key: @routing_key)
86
77
  end
87
78
 
88
79
  q.subscribe do |delivery, meta, msg|
@@ -128,16 +119,16 @@ module Fluent
128
119
 
129
120
  def parse_time( meta )
130
121
  if @time_header && meta[:headers][@time_header]
131
- Time.parse( meta[:headers][@time_header] ).to_i
122
+ Fluent::EventTime.from_time(Time.parse( meta[:headers][@time_header] ))
132
123
  else
133
- Time.new.to_i
124
+ Fluent::Engine.now
134
125
  end
135
126
  end
136
127
 
137
128
  def check_tls_configuration()
138
129
  if @tls
139
130
  unless @tls_key && @tls_cert
140
- raise ConfigError, "'tls_key' and 'tls_cert' must be all specified if tls is enabled."
131
+ raise Fluent::ConfigError, "'tls_key' and 'tls_cert' must be all specified if tls is enabled."
141
132
  end
142
133
  end
143
134
  end
@@ -145,13 +136,13 @@ module Fluent
145
136
  def get_connection_options()
146
137
  hosts = @hosts ||= Array.new(1, @host)
147
138
  opts = {
148
- :hosts => hosts, :port => @port, :vhost => @vhost,
149
- :pass => @pass, :user => @user, :ssl => @ssl,
150
- :verify_ssl => @verify_ssl, :heartbeat => @heartbeat,
151
- :tls => @tls,
152
- :tls_cert => @tls_cert,
153
- :tls_key => @tls_key,
154
- :verify_peer => @tls_verify_peer
139
+ hosts: hosts, port: @port, vhost: @vhost,
140
+ pass: @pass, user: @user, ssl: @ssl,
141
+ verify_ssl: @verify_ssl, heartbeat: @heartbeat,
142
+ tls: @tls,
143
+ tls_cert: @tls_cert,
144
+ tls_key: @tls_key,
145
+ verify_peer: @tls_verify_peer
155
146
  }
156
147
  opts[:tls_ca_certificates] = @tls_ca_certificates if @tls_ca_certificates
157
148
  return opts
@@ -159,4 +150,4 @@ module Fluent
159
150
 
160
151
  end # class AMQPInput
161
152
 
162
- end # module Fluent
153
+ end # module Fluent::Plugin
@@ -1,13 +1,17 @@
1
1
  require 'json'
2
- require 'fluent/output'
2
+ require 'fluent/plugin/output'
3
+ require "bunny"
3
4
 
4
-
5
- module Fluent
5
+ module Fluent::Plugin
6
6
  ##
7
7
  # AMQPOutput to be used as a Fluent MATCHER, sending messages to a RabbitMQ
8
8
  # messaging broker
9
- class AMQPOutput < BufferedOutput
10
- Plugin.register_output("amqp", self)
9
+ class AMQPOutput < Output
10
+ Fluent::Plugin.register_output("amqp", self)
11
+
12
+ helpers :compat_parameters
13
+
14
+ DEFAULT_BUFFER_TYPE = "memory"
11
15
 
12
16
  attr_accessor :connection
13
17
 
@@ -16,44 +20,44 @@ module Fluent
16
20
  attr_reader :channel
17
21
 
18
22
 
19
- config_param :host, :string, :default => nil
20
- config_param :hosts, :array, :default => nil
21
- config_param :user, :string, :default => "guest"
22
- config_param :pass, :string, :default => "guest", :secret => true
23
- config_param :vhost, :string, :default => "/"
24
- config_param :port, :integer, :default => 5672
25
- config_param :ssl, :bool, :default => false
26
- config_param :verify_ssl, :bool, :default => false
27
- config_param :heartbeat, :integer, :default => 60
28
- config_param :exchange, :string, :default => ""
29
- config_param :exchange_type, :string, :default => "direct"
30
- config_param :passive, :bool, :default => false
31
- config_param :durable, :bool, :default => false
32
- config_param :auto_delete, :bool, :default => false
33
- config_param :key, :string, :default => nil
34
- config_param :persistent, :bool, :default => false
35
- config_param :tag_key, :bool, :default => false
36
- config_param :tag_header, :string, :default => nil
37
- config_param :time_header, :string, :default => nil
38
- config_param :tls, :bool, :default => false
39
- config_param :tls_cert, :string, :default => nil
40
- config_param :tls_key, :string, :default => nil
41
- config_param :tls_ca_certificates, :array, :default => nil
42
- config_param :tls_verify_peer, :bool, :default => true
43
-
44
- def initialize
45
- super
46
- require "bunny"
23
+ config_param :host, :string, default: nil
24
+ config_param :hosts, :array, default: nil
25
+ config_param :user, :string, default: "guest"
26
+ config_param :pass, :string, default: "guest", secret: true
27
+ config_param :vhost, :string, default: "/"
28
+ config_param :port, :integer, default: 5672
29
+ config_param :ssl, :bool, default: false
30
+ config_param :verify_ssl, :bool, default: false
31
+ config_param :heartbeat, :integer, default: 60
32
+ config_param :exchange, :string, default: ""
33
+ config_param :exchange_type, :string, default: "direct"
34
+ config_param :passive, :bool, default: false
35
+ config_param :durable, :bool, default: false
36
+ config_param :auto_delete, :bool, default: false
37
+ config_param :key, :string, default: nil
38
+ config_param :persistent, :bool, default: false
39
+ config_param :tag_key, :bool, default: false
40
+ config_param :tag_header, :string, default: nil
41
+ config_param :time_header, :string, default: nil
42
+ config_param :tls, :bool, default: false
43
+ config_param :tls_cert, :string, default: nil
44
+ config_param :tls_key, :string, default: nil
45
+ config_param :tls_ca_certificates, :array, default: nil
46
+ config_param :tls_verify_peer, :bool, default: true
47
+
48
+ config_section :buffer do
49
+ config_set_default :@type, DEFAULT_BUFFER_TYPE
47
50
  end
48
51
 
49
52
  def configure(conf)
53
+ compat_parameters_convert(conf, :buffer)
50
54
  super
51
55
  @conf = conf
52
56
  unless @host || @hosts
53
- raise ConfigError, "'host' or 'hosts' must be specified."
57
+ raise Fluent::ConfigError, "'host' or 'hosts' must be specified."
54
58
  end
55
59
  unless @key || @tag_key
56
- raise ConfigError, "Either 'key' or 'tag_key' must be set."
60
+ raise Fluent::ConfigError, "Either 'key' or 'tag_key' must be set."
57
61
  end
58
62
  check_tls_configuration
59
63
  end
@@ -72,14 +76,18 @@ module Fluent
72
76
 
73
77
  log.info "Creating new exchange #{@exchange}"
74
78
  @channel = @connection.create_channel
75
- @exch = @channel.exchange(@exchange, :type => @exchange_type.intern,
76
- :passive => @passive, :durable => @durable,
77
- :auto_delete => @auto_delete)
79
+ @exch = @channel.exchange(@exchange, type: @exchange_type.intern,
80
+ passive: @passive, durable: @durable,
81
+ auto_delete: @auto_delete)
78
82
  end
79
83
 
80
84
  def shutdown
81
- super
82
85
  @connection.stop
86
+ super
87
+ end
88
+
89
+ def formatted_to_msgpack_binary
90
+ true
83
91
  end
84
92
 
85
93
  def format(tag, time, record)
@@ -92,7 +100,7 @@ module Fluent
92
100
  begin
93
101
  data = JSON.dump( data ) unless data.is_a?( String )
94
102
  log.debug "Sending message #{data}, :key => #{routing_key( tag)} :headers => #{headers(tag,time)}"
95
- @exch.publish(data, :key => routing_key( tag ), :persistent => @persistent, :headers => headers( tag, time ))
103
+ @exch.publish(data, key: routing_key( tag ), persistent: @persistent, headers: headers( tag, time ))
96
104
  rescue JSON::GeneratorError => e
97
105
  log.error "Failure converting data object to json string: #{e.message}"
98
106
  # Debug only - otherwise we may pollute the fluent logs with unparseable events and loop
@@ -134,7 +142,7 @@ module Fluent
134
142
  def check_tls_configuration()
135
143
  if @tls
136
144
  unless @tls_key && @tls_cert
137
- raise ConfigError, "'tls_key' and 'tls_cert' must be all specified if tls is enabled."
145
+ raise Fluent::ConfigError, "'tls_key' and 'tls_cert' must be all specified if tls is enabled."
138
146
  end
139
147
  end
140
148
  end
@@ -142,13 +150,13 @@ module Fluent
142
150
  def get_connection_options()
143
151
  hosts = @hosts ||= Array.new(1, @host)
144
152
  opts = {
145
- :hosts => hosts, :port => @port, :vhost => @vhost,
146
- :pass => @pass, :user => @user, :ssl => @ssl,
147
- :verify_ssl => @verify_ssl, :heartbeat => @heartbeat,
148
- :tls => @tls || nil,
149
- :tls_cert => @tls_cert,
150
- :tls_key => @tls_key,
151
- :verify_peer => @tls_verify_peer
153
+ hosts: hosts, port: @port, vhost: @vhost,
154
+ pass: @pass, user: @user, ssl: @ssl,
155
+ verify_ssl: @verify_ssl, heartbeat: @heartbeat,
156
+ tls: @tls || nil,
157
+ tls_cert: @tls_cert,
158
+ tls_key: @tls_key,
159
+ verify_peer: @tls_verify_peer
152
160
  }
153
161
  opts[:tls_ca_certificates] = @tls_ca_certificates if @tls_ca_certificates
154
162
  return opts
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-amqp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
5
- prerelease:
4
+ version: 0.10.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Hiromi Ishii
@@ -12,150 +11,130 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2016-10-07 00:00:00.000000000 Z
14
+ date: 2016-11-17 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: fluentd
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
- - - ! '>='
20
+ - - ">="
23
21
  - !ruby/object:Gem::Version
24
- version: '0'
25
- type: :runtime
26
- prerelease: false
27
- version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- - !ruby/object:Gem::Dependency
34
- name: amq-protocol
35
- requirement: !ruby/object:Gem::Requirement
36
- none: false
37
- requirements:
38
- - - <
22
+ version: 0.14.8
23
+ - - "<"
39
24
  - !ruby/object:Gem::Version
40
25
  version: '2'
41
26
  type: :runtime
42
27
  prerelease: false
43
28
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
29
  requirements:
46
- - - <
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.14.8
33
+ - - "<"
47
34
  - !ruby/object:Gem::Version
48
35
  version: '2'
49
36
  - !ruby/object:Gem::Dependency
50
37
  name: bunny
51
38
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
39
  requirements:
54
- - - <
40
+ - - ">="
55
41
  - !ruby/object:Gem::Version
56
- version: '2'
42
+ version: '1.7'
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: '3'
57
46
  type: :runtime
58
47
  prerelease: false
59
48
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
49
  requirements:
62
- - - <
50
+ - - ">="
63
51
  - !ruby/object:Gem::Version
64
- version: '2'
52
+ version: '1.7'
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: '3'
65
56
  - !ruby/object:Gem::Dependency
66
- name: json
57
+ name: bunny-mock
67
58
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
59
  requirements:
70
- - - <
60
+ - - ">="
71
61
  - !ruby/object:Gem::Version
72
- version: '2'
73
- type: :runtime
62
+ version: '1.0'
63
+ type: :development
74
64
  prerelease: false
75
65
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
66
  requirements:
78
- - - <
67
+ - - ">="
79
68
  - !ruby/object:Gem::Version
80
- version: '2'
69
+ version: '1.0'
81
70
  - !ruby/object:Gem::Dependency
82
71
  name: shoulda
83
72
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
73
  requirements:
86
- - - ! '>='
74
+ - - ">="
87
75
  - !ruby/object:Gem::Version
88
- version: '0'
76
+ version: 3.5.0
89
77
  type: :development
90
78
  prerelease: false
91
79
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
80
  requirements:
94
- - - ! '>='
81
+ - - ">="
95
82
  - !ruby/object:Gem::Version
96
- version: '0'
83
+ version: 3.5.0
97
84
  - !ruby/object:Gem::Dependency
98
85
  name: rake
99
86
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
87
  requirements:
102
- - - ! '>='
88
+ - - ">="
103
89
  - !ruby/object:Gem::Version
104
90
  version: '0'
105
91
  type: :development
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
94
  requirements:
110
- - - ! '>='
95
+ - - ">="
111
96
  - !ruby/object:Gem::Version
112
97
  version: '0'
113
98
  - !ruby/object:Gem::Dependency
114
99
  name: minitest
115
100
  requirement: !ruby/object:Gem::Requirement
116
- none: false
117
101
  requirements:
118
- - - <
102
+ - - "<"
119
103
  - !ruby/object:Gem::Version
120
104
  version: 5.0.0
121
105
  type: :development
122
106
  prerelease: false
123
107
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
108
  requirements:
126
- - - <
109
+ - - "<"
127
110
  - !ruby/object:Gem::Version
128
111
  version: 5.0.0
129
112
  - !ruby/object:Gem::Dependency
130
113
  name: test-unit
131
114
  requirement: !ruby/object:Gem::Requirement
132
- none: false
133
115
  requirements:
134
- - - ! '>='
116
+ - - ">="
135
117
  - !ruby/object:Gem::Version
136
118
  version: 3.1.0
137
119
  type: :development
138
120
  prerelease: false
139
121
  version_requirements: !ruby/object:Gem::Requirement
140
- none: false
141
122
  requirements:
142
- - - ! '>='
123
+ - - ">="
143
124
  - !ruby/object:Gem::Version
144
125
  version: 3.1.0
145
126
  - !ruby/object:Gem::Dependency
146
127
  name: simplecov
147
128
  requirement: !ruby/object:Gem::Requirement
148
- none: false
149
129
  requirements:
150
- - - ! '>='
130
+ - - ">="
151
131
  - !ruby/object:Gem::Version
152
132
  version: '0.10'
153
133
  type: :development
154
134
  prerelease: false
155
135
  version_requirements: !ruby/object:Gem::Requirement
156
- none: false
157
136
  requirements:
158
- - - ! '>='
137
+ - - ">="
159
138
  - !ruby/object:Gem::Version
160
139
  version: '0.10'
161
140
  description: AMQP input/output plugin for fluentd
@@ -165,35 +144,31 @@ extensions: []
165
144
  extra_rdoc_files:
166
145
  - LICENSE.txt
167
146
  files:
147
+ - LICENSE.txt
168
148
  - lib/fluent/plugin/in_amqp.rb
169
149
  - lib/fluent/plugin/out_amqp.rb
170
- - LICENSE.txt
171
150
  homepage: http://github.com/giraffi/fluent-plugin-amqp
172
151
  licenses:
173
152
  - Apache License, Version 2.0
153
+ metadata: {}
174
154
  post_install_message:
175
155
  rdoc_options: []
176
156
  require_paths:
177
157
  - lib
178
158
  required_ruby_version: !ruby/object:Gem::Requirement
179
- none: false
180
159
  requirements:
181
- - - ! '>='
160
+ - - ">="
182
161
  - !ruby/object:Gem::Version
183
162
  version: '0'
184
- segments:
185
- - 0
186
- hash: 3868625175639122764
187
163
  required_rubygems_version: !ruby/object:Gem::Requirement
188
- none: false
189
164
  requirements:
190
- - - ! '>='
165
+ - - ">="
191
166
  - !ruby/object:Gem::Version
192
- version: '0'
167
+ version: 2.1.0
193
168
  requirements: []
194
169
  rubyforge_project:
195
- rubygems_version: 1.8.24
170
+ rubygems_version: 2.5.1
196
171
  signing_key:
197
- specification_version: 3
172
+ specification_version: 4
198
173
  summary: AMQP input/output plugin or fluentd
199
174
  test_files: []