fluent-plugin-mongo 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,14 +10,17 @@
10
10
  # following attibutes are optional
11
11
  host fluenter
12
12
  port 10000
13
+
14
+ # Other buffer configurations here
13
15
  </match>
14
16
 
15
17
  == TODO
16
18
 
17
- === TimeSlicedOutput version
19
+ === More configuration
18
20
 
19
- Currently, MemoryBufferChunk requires String object.
20
- But, Mongo client can push event-record to server directory.
21
+ - Create Capped Collection
22
+ - Create Index
23
+ - etc
21
24
 
22
25
  === Infer collection name
23
26
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -1,12 +1,13 @@
1
1
  module Fluent
2
2
 
3
3
 
4
- class MongoOutput < Output
4
+ class MongoOutput < BufferedOutput
5
5
  Fluent::Plugin.register_output('mongo', self)
6
6
 
7
7
  def initialize
8
8
  super
9
9
  require 'mongo'
10
+ require 'msgpack'
10
11
  end
11
12
 
12
13
  def configure(conf)
@@ -29,12 +30,20 @@ class MongoOutput < Output
29
30
  @collection.db.connection.close
30
31
  end
31
32
 
32
- def emit(tag, event_stream, chain)
33
- event_stream.each { |event|
34
- @collection.insert(event.record)
35
- }
33
+ def format(tag, event)
34
+ event.record.to_msgpack
35
+ end
36
36
 
37
- chain.next
37
+ def write(chunk)
38
+ records = []
39
+ chunk.open { |io|
40
+ begin
41
+ MessagePack::Unpacker.new(io).each { |record| records << record }
42
+ rescue EOFError
43
+ # EOFError always occured when reached end of chunk.
44
+ end
45
+ }
46
+ @collection.insert(records)
38
47
  end
39
48
  end
40
49
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Masahiro Nakagawa