Skip to content

Commit 0a4bc19

Browse files
committed
simpify gems, by replace uuidtools with securerandom, given the requirement is ruby >= 1.9 already
Signed-off-by: Rich <[email protected]>
1 parent 1e535a0 commit 0a4bc19

File tree

4 files changed

+4
-23
lines changed

4 files changed

+4
-23
lines changed

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
source "http://rubygems.org"
22

3-
gem 'uuidtools'
4-
53
gemspec

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ E.g., "logs/" in the example configuration above.
342342
time-slice in text that are formatted with **time_slice_format**.
343343
* %{index} is the sequential number starts from 0, increments when multiple files are uploaded to S3 in the same time slice.
344344
* %{file_extension} depends on **store_as** parameter.
345-
* %{uuid_flush} a uuid that is replaced everytime the buffer will be flushed. If you want to use this placeholder, install `uuidtools` gem first.
345+
* %{uuid_flush} a uuid that is replaced everytime the buffer will be flushed.
346346
* %{hostname} is replaced with `Socket.gethostname` result.
347347
* %{hex_random} a random hex string that is replaced for each buffer chunk, not
348348
assured to be unique. This is used to follow a way of performance tuning, `Add

lib/fluent/plugin/out_s3.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require 'zlib'
66
require 'time'
77
require 'tempfile'
8+
require 'securerandom'
89

910
module Fluent::Plugin
1011
class S3Output < Output
@@ -384,7 +385,7 @@ def hex_random(chunk)
384385
end
385386

386387
def uuid_random
387-
::UUIDTools::UUID.random_create.to_s
388+
SecureRandom.uuid
388389
end
389390

390391
# This is stolen from Fluentd
@@ -441,17 +442,6 @@ def process_s3_object_key_format
441442
}
442443

443444
if @s3_object_key_format.include?('%{uuid_flush}')
444-
# test uuidtools works or not
445-
begin
446-
require 'uuidtools'
447-
rescue LoadError
448-
raise Fluent::ConfigError, "uuidtools gem not found. Install uuidtools gem first"
449-
end
450-
begin
451-
uuid_random
452-
rescue => e
453-
raise Fluent::ConfigError, "Generating uuid doesn't work. Can't use %{uuid_flush} on this environment. #{e}"
454-
end
455445
@uuid_flush_enabled = true
456446
end
457447

test/test_out_s3.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
require 'zlib'
1010
require 'fileutils'
1111
require 'timecop'
12-
require 'uuidtools'
1312
require 'ostruct'
1413

1514
include Fluent::Test::Helpers
@@ -349,17 +348,11 @@ def test_write_with_custom_s3_object_key_format
349348

350349
def test_write_with_custom_s3_object_key_format_containing_uuid_flush_placeholder
351350

352-
begin
353-
require 'uuidtools'
354-
rescue LoadError
355-
pend("uuidtools not found. skip this test")
356-
end
357-
358351
# Partial mock the S3Bucket, not to make an actual connection to Amazon S3
359352
setup_mocks(true)
360353

361354
uuid = "5755e23f-9b54-42d8-8818-2ea38c6f279e"
362-
stub(::UUIDTools::UUID).random_create{ uuid }
355+
stub(::SecureRandom).uuid{ uuid }
363356

364357
s3_local_file_path = "/tmp/s3-test.txt"
365358
s3path = "log/events/ts=20110102-13/events_0-#{uuid}.gz"

0 commit comments

Comments
 (0)