fluent-plugin-gstore 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ # gem "shoulda", ">= 0"
10
+ # gem "rdoc", "~> 3.12"
11
+ gem "bundler", ">= 1.0.0"
12
+ gem "jeweler", ">= 1.8.4"
13
+ # gem "rcov", ">= 0"
14
+ end
15
+ gem "gstore", "=0.2.1"
@@ -0,0 +1,16 @@
1
+
2
+ This software is licensed under the Apache 2 license, quoted below.
3
+
4
+ Copyright (c) 2012 Tatsuo Ikeda <jp.ne.co.jp@gmail.com>
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
+ use this file except in compliance with the License. You may obtain a copy of
8
+ the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+ License for the specific language governing permissions and limitations under
16
+ the License.
@@ -0,0 +1,42 @@
1
+
2
+
3
+ Google Cloud Storage output plugin for the Fluent.
4
+ ====================================================
5
+
6
+ [Google Cloud Storage](http://cloud.google.com/products/cloud-storage.html) output plugin for the [Fluent](http://fluentd.org/).
7
+
8
+
9
+ Installation
10
+ ==============
11
+
12
+ Configuration
13
+
14
+ ```ruby
15
+ <match pattern>
16
+ type gstore
17
+
18
+ gstore_key_id API_ACCESS_KEY
19
+ gstore_sec_key API_SECRET_KEY
20
+ gstore_bucket BUCKET_NAME
21
+ path logs/
22
+ buffer_path /var/log/fluent/gstore
23
+
24
+ time_slice_format %Y%m%d-%H
25
+ time_slice_wait 10m
26
+ utc
27
+ </match>
28
+ ```
29
+
30
+
31
+ Setup
32
+ =====
33
+
34
+ ```bash
35
+ $ gem install fluent-plugin-gstore
36
+ ```
37
+
38
+
39
+ LICENSE
40
+ ========
41
+
42
+ Apache License, Version 2.0
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "fluent-plugin-gstore"
18
+ gem.homepage = "https://github.com/ikeikeikeike/fluent-plugin-gstore"
19
+ gem.license = "Apache License, Version 2.0"
20
+ gem.summary = %Q{Google Cloud Storage output plugin for the Fluent.}
21
+ gem.description = %Q{Google Cloud Storage output plugin for the Fluent.}
22
+ gem.email = "jp.ne.co.jp@gmail.com"
23
+ gem.authors = ["Tatsuo Ikeda"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ #require 'rake/testtask'
29
+ #Rake::TestTask.new(:test) do |test|
30
+ # test.libs << 'lib' << 'test'
31
+ # test.pattern = 'test/**/test_*.rb'
32
+ # test.verbose = true
33
+ #end
34
+
35
+ #require 'rcov/rcovtask'
36
+ #Rcov::RcovTask.new do |test|
37
+ # test.libs << 'test'
38
+ # test.pattern = 'test/**/test_*.rb'
39
+ # test.verbose = true
40
+ # test.rcov_opts << '--exclude "gems/*"'
41
+ #end
42
+
43
+ task :default => :test
44
+
45
+ require 'rdoc/task'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "fluent-plugin-gstore #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.2
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "fluent-plugin-gstore"
8
+ s.version = "0.3.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tatsuo Ikeda"]
12
+ s.date = "2012-08-10"
13
+ s.description = "Google Cloud Storage output plugin for the Fluent."
14
+ s.email = "jp.ne.co.jp@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "LICENSE.txt",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "fluent-plugin-gstore.gemspec",
27
+ "lib/fluent/plugin/out_gstore.rb",
28
+ "test/helper.rb",
29
+ "test/test_fluent-plugin-gstore.rb"
30
+ ]
31
+ s.homepage = "https://github.com/ikeikeikeike/fluent-plugin-gstore"
32
+ s.licenses = ["Apache License, Version 2.0"]
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = "1.8.17"
35
+ s.summary = "Google Cloud Storage output plugin for the Fluent."
36
+
37
+ if s.respond_to? :specification_version then
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
+ s.add_runtime_dependency(%q<gstore>, ["= 0.2.1"])
42
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
43
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
44
+ else
45
+ s.add_dependency(%q<gstore>, ["= 0.2.1"])
46
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
47
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<gstore>, ["= 0.2.1"])
51
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
52
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
53
+ end
54
+ end
55
+
@@ -0,0 +1,79 @@
1
+ module Fluent
2
+
3
+
4
+ class GStoreOutput < Fluent::TimeSlicedOutput
5
+ Fluent::Plugin.register_output('gstore', self)
6
+
7
+ def initialize
8
+ super
9
+ require 'gstore'
10
+ require 'kconv'
11
+ require 'zlib'
12
+ require 'time'
13
+ require 'tempfile'
14
+ require "pathname"
15
+ require "rexml/document"
16
+ end
17
+
18
+ config_param :path, :string, :default => ""
19
+ config_param :time_format, :string, :default => nil
20
+
21
+ config_param :gstore_key_id, :string
22
+ config_param :gstore_sec_key, :string
23
+ config_param :gstore_bucket, :string
24
+
25
+ def configure(conf)
26
+ super
27
+ @timef = TimeFormatter.new(@time_format, @localtime)
28
+ end
29
+
30
+ def start
31
+ super
32
+ options = {
33
+ :access_key => @gstore_key_id,
34
+ :secret_key => @gstore_sec_key
35
+ }
36
+ @gstore = GStore::Client.new(options)
37
+ end
38
+
39
+ def format(tag, time, record)
40
+ time_str = @timef.format(time)
41
+ "#{time_str}\t#{tag}\t#{record.to_json}\n"
42
+ end
43
+
44
+ def exists?(source)
45
+ begin
46
+ REXML::Document.new source
47
+ # :TODO
48
+ false
49
+ rescue REXML::ParseException => e
50
+ true
51
+ rescue Exception => e
52
+ true
53
+ end
54
+ end
55
+
56
+ def write(chunk)
57
+ i = 0
58
+ begin
59
+ gstorepath = "#{@path}#{chunk.key}_#{i}.gz"
60
+ i += 1
61
+ end while exists? @gstore.get_object(@gstore_bucket, gstorepath)
62
+
63
+ tmp = Tempfile.new("gstore-")
64
+ w = Zlib::GzipWriter.new(tmp)
65
+ begin
66
+ chunk.write_to(w)
67
+ w.close
68
+ @gstore.put_object(
69
+ @gstore_bucket,
70
+ gstorepath,
71
+ :data => Pathname.new(tmp.path).read())
72
+ ensure
73
+ w.close rescue nil
74
+ end
75
+ end
76
+ end
77
+
78
+
79
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'fluent-plugin-gstore'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestFluentPluginGstore < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-gstore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tatsuo Ikeda
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-10 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gstore
16
+ requirement: &12635680 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - =
20
+ - !ruby/object:Gem::Version
21
+ version: 0.2.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *12635680
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &12635200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *12635200
36
+ - !ruby/object:Gem::Dependency
37
+ name: jeweler
38
+ requirement: &12634700 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.8.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *12634700
47
+ description: Google Cloud Storage output plugin for the Fluent.
48
+ email: jp.ne.co.jp@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - LICENSE.txt
53
+ - README.md
54
+ files:
55
+ - .document
56
+ - Gemfile
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
60
+ - VERSION
61
+ - fluent-plugin-gstore.gemspec
62
+ - lib/fluent/plugin/out_gstore.rb
63
+ - test/helper.rb
64
+ - test/test_fluent-plugin-gstore.rb
65
+ homepage: https://github.com/ikeikeikeike/fluent-plugin-gstore
66
+ licenses:
67
+ - Apache License, Version 2.0
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ segments:
79
+ - 0
80
+ hash: 2680384576812547495
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.17
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Google Cloud Storage output plugin for the Fluent.
93
+ test_files: []