fluent-plugin-couch 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/Rakefile +3 -2
  2. data/VERSION +1 -1
  3. data/lib/fluent/plugin/out_couch.rb +22 -51
  4. metadata +17 -6
data/Rakefile CHANGED
@@ -6,13 +6,14 @@ begin
6
6
  require 'jeweler'
7
7
  Jeweler::Tasks.new do |gemspec|
8
8
  gemspec.name = "fluent-plugin-couch"
9
- gemspec.summary = "CouchDB output plugin for Fluent event collector"
9
+ gemspec.summary = "CouchDB output plugin for Fluentd event collector"
10
10
  gemspec.author = "Yudai Odagiri"
11
11
  gemspec.email = "ixixizko@gmail.com"
12
- gemspec.homepage = "http://github.com/fluent"
12
+ gemspec.homepage = "http://github.com/ixixi/fluent-plugin-couch"
13
13
  gemspec.has_rdoc = false
14
14
  gemspec.require_paths = ["lib"]
15
15
  gemspec.add_dependency "fluentd", "~> 0.10.0"
16
+ gemspec.add_dependency "couchrest", "~> 1.1.2"
16
17
  gemspec.test_files = Dir["test/**/*.rb"]
17
18
  gemspec.files = Dir["lib/**/*", "test/**/*.rb"] + %w[VERSION AUTHORS Rakefile]
18
19
  gemspec.executables = []
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -1,46 +1,5 @@
1
-
2
- module Couch
3
- require 'net/http'
4
- class Server
5
- def initialize(host, port, options = nil)
6
- @host = host
7
- @port = port
8
- @options = options
9
- end
10
-
11
- def delete(uri)
12
- request(Net::HTTP::Delete.new(uri))
13
- end
14
-
15
- def get(uri)
16
- request(Net::HTTP::Get.new(uri))
17
- end
18
-
19
- def put(uri, json)
20
- req = Net::HTTP::Put.new(uri)
21
- req["content-type"] = "application/json"
22
- req.body = json
23
- request(req)
24
- end
25
-
26
- def post(uri, json)
27
- req = Net::HTTP::Post.new(uri)
28
- req["content-type"] = "application/json"
29
- req.body = json
30
- request(req)
31
- end
32
-
33
- def request(req)
34
- res = Net::HTTP.start(@host, @port) { |http|http.request(req) }
35
- res
36
- end
37
-
38
- end
39
- end
40
-
41
1
  module Fluent
42
2
  class CouchOutput < BufferedOutput
43
-
44
3
  include SetTagKeyMixin
45
4
  config_set_default :include_tag_key, false
46
5
 
@@ -48,16 +7,19 @@ module Fluent
48
7
  config_set_default :include_time_key, true
49
8
 
50
9
  Fluent::Plugin.register_output('couch', self)
51
-
52
- config_param :database, :string => nil do |val|
53
- '/'+val
54
- end
10
+
11
+ config_param :database, :string
12
+
55
13
  config_param :host, :string, :default => 'localhost'
56
14
  config_param :port, :string, :default => '5984'
57
15
 
16
+ config_param :refresh_view_index , :string, :default => nil
17
+
58
18
  def initialize
59
19
  super
20
+ Encoding.default_internal = 'UTF-8'
60
21
  require 'msgpack'
22
+ require 'couchrest'
61
23
  end
62
24
 
63
25
  def configure(conf)
@@ -66,8 +28,13 @@ module Fluent
66
28
 
67
29
  def start
68
30
  super
69
- @couch = Couch::Server.new(@host, @port)
70
- @couch.put(@database, "")
31
+ @db = CouchRest.database("http://#{@host}:#{@port}/#{@database}")
32
+ @views = []
33
+ unless @refresh_view_index.nil?
34
+ @db.get("_design/#{@refresh_view_index}")['views'].each do |view_name,func|
35
+ @views.push([@refresh_view_index,view_name])
36
+ end
37
+ end
71
38
  end
72
39
 
73
40
  def shutdown
@@ -81,11 +48,15 @@ module Fluent
81
48
  def write(chunk)
82
49
  records = []
83
50
  chunk.msgpack_each {|record| records << record }
84
- @couch.post(@database+'/_bulk_docs', {"all_or_nothing"=>true, "docs"=>records}.to_json)
51
+ @db.bulk_save(records)
52
+ update_view_index()
53
+ end
85
54
 
86
- #for record in records
87
- # @couch.post(@database,record.to_json)
88
- #end
55
+ def update_view_index()
56
+ @views.each do |design,view|
57
+ @db.view("#{design}/#{view}",{"limit"=>"0"})
58
+ end
89
59
  end
60
+
90
61
  end
91
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-couch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-16 00:00:00.000000000Z
12
+ date: 2012-02-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
16
- requirement: &70156152291940 !ruby/object:Gem::Requirement
16
+ requirement: &70210464681300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: 0.10.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70156152291940
24
+ version_requirements: *70210464681300
25
+ - !ruby/object:Gem::Dependency
26
+ name: couchrest
27
+ requirement: &70210464680780 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70210464680780
25
36
  description:
26
37
  email: ixixizko@gmail.com
27
38
  executables: []
@@ -34,7 +45,7 @@ files:
34
45
  - VERSION
35
46
  - lib/fluent/plugin/out_couch.rb
36
47
  - README.rdoc
37
- homepage: http://github.com/fluent
48
+ homepage: http://github.com/ixixi/fluent-plugin-couch
38
49
  licenses: []
39
50
  post_install_message:
40
51
  rdoc_options: []
@@ -57,5 +68,5 @@ rubyforge_project:
57
68
  rubygems_version: 1.8.7
58
69
  signing_key:
59
70
  specification_version: 3
60
- summary: CouchDB output plugin for Fluent event collector
71
+ summary: CouchDB output plugin for Fluentd event collector
61
72
  test_files: []