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 +6 -3
- data/VERSION +1 -1
- data/lib/fluent/plugin/out_mongo.rb +15 -6
- metadata +2 -2
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
|
-
===
|
19
|
+
=== More configuration
|
18
20
|
|
19
|
-
|
20
|
-
|
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.2.0
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module Fluent
|
2
2
|
|
3
3
|
|
4
|
-
class MongoOutput <
|
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
|
33
|
-
|
34
|
-
|
35
|
-
}
|
33
|
+
def format(tag, event)
|
34
|
+
event.record.to_msgpack
|
35
|
+
end
|
36
36
|
|
37
|
-
|
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
|
|