fluent-plugin-s3 0.3.0 → 0.3.1

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.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Release 0.3.1 - 2013/03/28
2
+
3
+ * Support json and text mime-types
4
+ https://github.com/fluent/fluent-plugin-s3/pull/20
5
+
6
+
1
7
  Release 0.3.0 - 2013/02/19
2
8
 
3
9
  * Enable dynamic and configurable S3 object kyes
@@ -31,9 +31,9 @@ Simply use RubyGems:
31
31
  utc
32
32
  </match>
33
33
 
34
- [aws_key_id (required)] AWS access key id.
34
+ [aws_key_id] AWS access key id. This parameter is required when your agent is not running on EC2 instance with an IAM Instance Profile.
35
35
 
36
- [aws_sec_key (required)] AWS secret key.
36
+ [aws_sec_key] AWS secret key. This parameter is required when your agent is not running on EC2 instance with an IAM Instance Profile.
37
37
 
38
38
  [s3_bucket (required)] S3 bucket name.
39
39
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -29,6 +29,7 @@ class S3Output < Fluent::TimeSlicedOutput
29
29
  config_param :s3_bucket, :string
30
30
  config_param :s3_endpoint, :string, :default => nil
31
31
  config_param :s3_object_key_format, :string, :default => "%{path}%{time_slice}_%{index}.%{file_extension}"
32
+ config_param :store_as, :string, :default => "gzip"
32
33
  config_param :auto_create_bucket, :bool, :default => true
33
34
 
34
35
  attr_reader :bucket
@@ -59,6 +60,12 @@ class S3Output < Fluent::TimeSlicedOutput
59
60
  end
60
61
  end
61
62
 
63
+ @ext, @mime_type = case @store_as
64
+ when 'gzip' then ['gz', 'application/x-gzip']
65
+ when 'json' then ['json', 'application/json']
66
+ else ['txt', 'text/plain']
67
+ end
68
+
62
69
  @timef = TimeFormatter.new(@time_format, @localtime)
63
70
  end
64
71
 
@@ -101,11 +108,12 @@ class S3Output < Fluent::TimeSlicedOutput
101
108
 
102
109
  def write(chunk)
103
110
  i = 0
111
+
104
112
  begin
105
113
  values_for_s3_object_key = {
106
114
  "path" => @path,
107
115
  "time_slice" => chunk.key,
108
- "file_extension" => "gz",
116
+ "file_extension" => @ext,
109
117
  "index" => i
110
118
  }
111
119
  s3path = @s3_object_key_format.gsub(%r(%{[^}]+})) { |expr|
@@ -115,11 +123,16 @@ class S3Output < Fluent::TimeSlicedOutput
115
123
  end while @bucket.objects[s3path].exists?
116
124
 
117
125
  tmp = Tempfile.new("s3-")
118
- w = Zlib::GzipWriter.new(tmp)
119
126
  begin
120
- chunk.write_to(w)
121
- w.close
122
- @bucket.objects[s3path].write(Pathname.new(tmp.path), :content_type => 'application/x-gzip')
127
+ if @store_as == "gzip"
128
+ w = Zlib::GzipWriter.new(tmp)
129
+ chunk.write_to(w)
130
+ w.close
131
+ else
132
+ chunk.write_to(tmp)
133
+ tmp.close
134
+ end
135
+ @bucket.objects[s3path].write(Pathname.new(tmp.path), :content_type => @mime_type)
123
136
  ensure
124
137
  tmp.close(true) rescue nil
125
138
  w.close rescue nil
@@ -39,6 +39,24 @@ class S3OutputTest < Test::Unit::TestCase
39
39
  assert_equal 'test_bucket', d.instance.s3_bucket
40
40
  assert_equal 'log', d.instance.path
41
41
  assert d.instance.instance_variable_get(:@use_ssl)
42
+ assert_equal 'gz', d.instance.instance_variable_get(:@ext)
43
+ assert_equal 'application/x-gzip', d.instance.instance_variable_get(:@mime_type)
44
+ end
45
+
46
+ def test_configure_with_mime_type_json
47
+ conf = CONFIG.clone
48
+ conf << "\nstore_as json\n"
49
+ d = create_driver(conf)
50
+ assert_equal 'json', d.instance.instance_variable_get(:@ext)
51
+ assert_equal 'application/json', d.instance.instance_variable_get(:@mime_type)
52
+ end
53
+
54
+ def test_configure_with_mime_type_text
55
+ conf = CONFIG.clone
56
+ conf << "\nstore_as text\n"
57
+ d = create_driver(conf)
58
+ assert_equal 'txt', d.instance.instance_variable_get(:@ext)
59
+ assert_equal 'text/plain', d.instance.instance_variable_get(:@mime_type)
42
60
  end
43
61
 
44
62
  def test_format
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-19 00:00:00.000000000 Z
12
+ date: 2013-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: -741948344279215557
139
+ hash: -4273077554576087642
140
140
  required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  none: false
142
142
  requirements:
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: -741948344279215557
148
+ hash: -4273077554576087642
149
149
  requirements: []
150
150
  rubyforge_project:
151
151
  rubygems_version: 1.8.23