daioikachan 0.0.2 → 0.0.3

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: 63ee532c54d5c3cbcf00169ee3d1b2fb6621c917
4
- data.tar.gz: 0d3b4eacfbf125714a467a5544dfd6c50752a225
3
+ metadata.gz: 8f5aaa06960399af8c0db1b659792fbe07b64e8b
4
+ data.tar.gz: 3d719dd5b2d8fb8d587a6253e97495847240386b
5
5
  SHA512:
6
- metadata.gz: c59f72eac8f078a362092ba2ddbebfe52cd28894a4bb772f8782c76b8f95d9e65905fa6493cd18456f478a8ce7cd03bd59f93123569e8ba396ced3c0e3a36657
7
- data.tar.gz: 89968e0ddd67d52b3f083c8f0bcca07807f6bb3d983b59068888e9ef7e80097d056fcd1f4d6ad3c59422694634c7e5a8a6cb1c2dd372cbc3b39e137b5a539ef6
6
+ metadata.gz: af6e9a5b261f683988c5287ffd7009219ee32731d8113de0b8a19460028c5cc15d60b470972a28ef94266bb1e927f18845ecebc1fda8ae01bb36d7b9eec4ee26
7
+ data.tar.gz: 9b970c33412b8524e5a3422293e8939875056c5c4def588f3091d404c39c957307b796a5d032cf5c0b58d522ef2471f06de00394e731825637472286b38f3af5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.0.3 (2015/03/25)
2
+
3
+ Changes:
4
+
5
+ * fluent-plugin-irc v0.0.7 has been released. Use it.
6
+
1
7
  # 0.0.2 (2015/03/23)
2
8
 
3
9
  Enhancements:
data/README.md CHANGED
@@ -74,7 +74,7 @@ See [config-file](http://docs.fluentd.org/articles/config-file) documentation of
74
74
  See following pages for built-in plugins.
75
75
 
76
76
  * [in_daioikachan](./README/in_daioikachan.md)
77
- * [fluent-plugin-irc](./README/out_irc.md)
77
+ * [fluent-plugin-irc](https://github.com/choplin/fluent-plugin-irc)
78
78
  * [fluent-plugin-slack](https://github.com/sowawa/fluent-plugin-slack)
79
79
 
80
80
  If you need other backends, search other fluentd output plugins and add them. Enjoy!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/daioikachan.gemspec CHANGED
@@ -19,8 +19,7 @@ Gem::Specification.new do |gem|
19
19
  gem.add_dependency "fluentd", "~> 0.12.0"
20
20
  gem.add_dependency "dotenv"
21
21
  gem.add_dependency "puma"
22
- # gem.add_dependency "fluent-plugin-irc"
23
- gem.add_dependency "irc_parser"
22
+ gem.add_dependency "fluent-plugin-irc", ">= 0.0.7"
24
23
  gem.add_dependency "fluent-plugin-slack", ">= 0.5.0"
25
24
  gem.add_development_dependency "rake"
26
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daioikachan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-23 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: irc_parser
56
+ name: fluent-plugin-irc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.0.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.0.7
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fluent-plugin-slack
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +108,6 @@ files:
108
108
  - LICENSE
109
109
  - README.md
110
110
  - README/in_daioikachan.md
111
- - README/out_irc.md
112
111
  - Rakefile
113
112
  - VERSION
114
113
  - bin/daioikachan
@@ -116,7 +115,6 @@ files:
116
115
  - examples/example.conf
117
116
  - examples/multi_slack.conf
118
117
  - lib/fluent/plugin/in_daioikachan.rb
119
- - lib/fluent/plugin/out_irc.rb
120
118
  - test/helper.rb
121
119
  - test/plugin/test_in_daioikachan.rb
122
120
  homepage: https://github.com/sonots/daioikachan
data/README/out_irc.md DELETED
@@ -1,58 +0,0 @@
1
- # Fluent::Plugin::Irc, a plugin for [Fluentd](http://fluentd.org)
2
-
3
- [![Build Status](https://travis-ci.org/choplin/fluent-plugin-irc.svg)](https://travis-ci.org/choplin/fluent-plugin-irc)
4
-
5
- Fluent plugin to send messages to IRC server
6
-
7
- ## Installation
8
-
9
- `$ fluent-gem install fluent-plugin-irc`
10
-
11
- ## Configuration
12
-
13
- ### Example
14
-
15
- ```
16
- <match **>
17
- type irc
18
- host localhost
19
- port 6667
20
- channel fluentd
21
- nick fluentd
22
- user fluentd
23
- real fluentd
24
- message notice: %s [%s] %s
25
- out_keys tag,time,message
26
- time_key time
27
- time_format %Y/%m/%d %H:%M:%S
28
- tag_key tag
29
- </match>
30
- ```
31
-
32
- ### Parameter
33
-
34
- |parameter|description|default|
35
- |---|---|---|
36
- |host|IRC server host|localhost|
37
- |port|IRC server port number|6667|
38
- |channel|channel to send messages (without first '#')||
39
- |channel_keys|keys used to format channel. %s will be replaced with value specified by channel_keys if this option is used|nil|
40
- |nick|nickname registerd of IRC|fluentd|
41
- |user|user name registerd of IRC|fluentd|
42
- |real|real name registerd of IRC|fluentd|
43
- |message|message format. %s will be replaced with value specified by out_keys||
44
- |out_keys|keys used to format messages||
45
- |time_key|key name for time|time|
46
- |time_format|time format. This will be formatted with Time#strftime.|%Y/%m/%d %H:%M:%S|
47
- |tag_key|key name for tag|tag|
48
- |command|irc command. `privmsg` or `notice`|privmsg|
49
- |command_keys|keys used to format command. %s will be replaced with value specified by command_keys if this option is used|nil|
50
- |send_interval|interval (sec) to send message. defence Excess Flood|2|
51
- |max_send_queue|maximum size of send message queue|100|
52
-
53
- ## Copyright
54
-
55
- <table>
56
- <tr><td>Copyright</td><td>Copyright (c) 2015 OKUNO Akihiro</td></tr>
57
- <tr><td>License</td><td>Apache License, Version 2.0</td></tr>
58
- </table>
@@ -1,292 +0,0 @@
1
- module Fluent
2
- class IRCOutput < Fluent::Output
3
- Fluent::Plugin.register_output('irc', self)
4
-
5
- include SetTimeKeyMixin
6
- include SetTagKeyMixin
7
-
8
- config_set_default :include_time_key, true
9
- config_set_default :include_tag_key, true
10
-
11
- config_param :host , :string , :default => 'localhost'
12
- config_param :port , :integer , :default => 6667
13
- config_param :channel , :string
14
- config_param :channel_keys, :default => nil do |val|
15
- val.split(',')
16
- end
17
- config_param :nick , :string , :default => 'fluentd'
18
- config_param :user , :string , :default => 'fluentd'
19
- config_param :real , :string , :default => 'fluentd'
20
- config_param :password , :string , :default => nil
21
- config_param :message , :string
22
- config_param :out_keys do |val|
23
- val.split(',')
24
- end
25
- config_param :time_key , :string , :default => 'time'
26
- config_param :time_format , :string , :default => '%Y/%m/%d %H:%M:%S'
27
- config_param :tag_key , :string , :default => 'tag'
28
- config_param :command , :string , :default => 'privmsg'
29
- config_param :command_keys, :default => nil do |val|
30
- val.split(',')
31
- end
32
-
33
- config_param :blocking_timeout, :time, :default => 0.5
34
- config_param :max_send_queue, :integer, :default => 100
35
- config_param :send_interval, :time, :default => 2
36
-
37
- COMMAND_MAP = {
38
- 'priv_msg' => :priv_msg,
39
- 'privmsg' => :priv_msg,
40
- 'notice' => :notice,
41
- }
42
-
43
- # To support log_level option implemented by Fluentd v0.10.43
44
- unless method_defined?(:log)
45
- define_method("log") { $log }
46
- end
47
-
48
- attr_reader :conn # for test
49
-
50
- def initialize
51
- super
52
- require 'irc_parser'
53
- end
54
-
55
- def configure(conf)
56
- super
57
-
58
- begin
59
- @message % (['1'] * @out_keys.length)
60
- rescue ArgumentError
61
- raise Fluent::ConfigError, "string specifier '%s' and out_keys specification mismatch"
62
- end
63
-
64
- if @channel_keys
65
- begin
66
- @channel % (['1'] * @channel_keys.length)
67
- rescue ArgumentError
68
- raise Fluent::ConfigError, "string specifier '%s' and channel_keys specification mismatch"
69
- end
70
- end
71
- @channel = '#'+@channel
72
-
73
- if @command_keys
74
- begin
75
- @command % (['1'] * @command_keys.length)
76
- rescue ArgumentError
77
- raise Fluent::ConfigError, "string specifier '%s' and command_keys specification mismatch"
78
- end
79
- else
80
- unless @command = COMMAND_MAP[@command]
81
- raise Fluent::ConfigError, "command must be one of #{COMMAND_MAP.keys.join(', ')}"
82
- end
83
- end
84
-
85
- @send_queue = []
86
- end
87
-
88
- def start
89
- super
90
-
91
- begin
92
- @loop = Coolio::Loop.new
93
- @conn = create_connection
94
- @timer = TimerWatcher.new(@send_interval, true, log, &method(:on_timer))
95
- @loop.attach(@timer)
96
- @thread = Thread.new(&method(:run))
97
- rescue => e
98
- puts e
99
- raise Fluent::ConfigError, "failed to connect IRC server #{@host}:#{@port}"
100
- end
101
- end
102
-
103
- def shutdown
104
- super
105
- @loop.watchers.each { |w| w.detach }
106
- @loop.stop
107
- @conn.close
108
- @thread.join
109
- end
110
-
111
- def run
112
- @loop.run(@blocking_timeout)
113
- rescue => e
114
- log.error "unexpected error", :error => e, :error_class => e.class
115
- log.error_backtrace
116
- end
117
-
118
- def emit(tag, es, chain)
119
- chain.next
120
-
121
- if @conn.closed?
122
- log.warn "out_irc: connection is closed. try to reconnect"
123
- @conn = create_connection
124
- end
125
-
126
- es.each do |time,record|
127
- if @send_queue.size >= @max_send_queue
128
- log.warn "out_irc: send queue size exceeded max_send_queue(#{@max_send_queue}), discards"
129
- break
130
- end
131
-
132
- filter_record(tag, time, record)
133
- command, channel, message = build_command(record), build_channel(record), build_message(record)
134
- log.debug { "out_irc: push {command:\"#{command}\", channel:\"#{channel}\", message:\"#{message}\"}" }
135
- @send_queue.push([command, channel, message])
136
- end
137
- end
138
-
139
- def on_timer
140
- return if @send_queue.empty?
141
- command, channel, message = @send_queue.shift
142
- log.info { "out_irc: send {command:\"#{command}\", channel:\"#{channel}\", message:\"#{message}\"}" }
143
- @conn.send_message(command, channel, message)
144
- end
145
-
146
- private
147
-
148
- def create_connection
149
- conn = IRCConnection.connect(@host, @port)
150
- conn.log = log
151
- conn.nick = @nick
152
- conn.user = @user
153
- conn.real = @real
154
- conn.password = @password
155
- conn.attach(@loop)
156
- conn
157
- end
158
-
159
- def build_message(record)
160
- values = fetch_keys(record, @out_keys)
161
- @message % values
162
- end
163
-
164
- def build_channel(record)
165
- return @channel unless @channel_keys
166
-
167
- values = fetch_keys(record, @channel_keys)
168
- @channel % values
169
- end
170
-
171
- def build_command(record)
172
- return @command unless @command_keys
173
-
174
- values = fetch_keys(record, @command_keys)
175
- unless command = COMMAND_MAP[@command % values]
176
- log.warn "out_irc: command is not one of #{COMMAND_MAP.keys.join(', ')}, use privmsg"
177
- end
178
- command || :priv_msg
179
- end
180
-
181
- def fetch_keys(record, keys)
182
- Array(keys).map do |key|
183
- begin
184
- record.fetch(key).to_s
185
- rescue KeyError
186
- log.warn "out_irc: the specified key '#{key}' not found in record. [#{record}]"
187
- ''
188
- end
189
- end
190
- end
191
-
192
- class TimerWatcher < Coolio::TimerWatcher
193
- def initialize(interval, repeat, log, &callback)
194
- @callback = callback
195
- @log = log
196
- super(interval, repeat)
197
- end
198
-
199
- def on_timer
200
- @callback.call
201
- rescue
202
- @log.error $!.to_s
203
- @log.error_backtrace
204
- end
205
- end
206
-
207
- class IRCConnection < Cool.io::TCPSocket
208
- attr_reader :joined # for test
209
- attr_accessor :log, :nick, :user, :real, :password
210
-
211
- def initialize(*args)
212
- super
213
- @joined = {}
214
- end
215
-
216
- def on_connect
217
- if @password
218
- IRCParser.message(:pass) do |m|
219
- m.password = @password
220
- write m
221
- end
222
- end
223
- IRCParser.message(:nick) do |m|
224
- m.nick = @nick
225
- write m
226
- end
227
- IRCParser.message(:user) do |m|
228
- m.user = @user
229
- m.postfix = @real
230
- write m
231
- end
232
- end
233
-
234
- def on_read(data)
235
- err_nick_name_in_use = nil
236
- data.each_line do |line|
237
- begin
238
- msg = IRCParser.parse(line)
239
- log.debug { "out_irc: on_read :#{msg.class.to_sym}" }
240
- case msg.class.to_sym
241
- when :rpl_welcome
242
- log.info { "out_irc: welcome \"#{msg.nick}\" to \"#{msg.prefix}\"" }
243
- when :ping
244
- IRCParser.message(:pong) do |m|
245
- m.target = msg.target
246
- m.body = msg.body
247
- write m
248
- end
249
- when :join
250
- log.info { "out_irc: joined to #{msg.channels.join(', ')}" }
251
- msg.channels.each {|channel| @joined[channel] = true }
252
- when :err_nick_name_in_use
253
- log.warn "out_irc: nickname \"#{msg.error_nick}\" is already in use. use \"#{msg.error_nick}_\" instead."
254
- err_nick_name_in_use = true
255
- @nick = "#{msg.error_nick}_"
256
- when :error
257
- log.warn "out_irc: an error occured. \"#{msg.error_message}\""
258
- end
259
- rescue
260
- #TODO
261
- end
262
- end
263
-
264
- if err_nick_name_in_use
265
- self.on_connect
266
- end
267
- end
268
-
269
- def joined?(channel)
270
- @joined[channel]
271
- end
272
-
273
- def join(channel)
274
- IRCParser.message(:join) do |m|
275
- m.channels = channel
276
- write m
277
- end
278
- log.debug { "out_irc: join to #{channel}" }
279
- end
280
-
281
- def send_message(command, channel, message)
282
- join(channel) unless joined?(channel)
283
- IRCParser.message(command) do |m|
284
- m.target = channel
285
- m.body = message
286
- write m
287
- end
288
- channel # return channel for test
289
- end
290
- end
291
- end
292
- end