Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AWS SDK conflict with s3 plugin, down to v2 #131

Merged
merged 1 commit into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ matrix:
gemfile: Gemfile
- rvm: 2.1.10
os: linux
gemfile: gemfiles/Gemfile.fluentd-0.12
gemfile: gemfiles/Gemfile.td-agent-2.3.5

script: bundle exec rake test

Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.

.PHONY: run run-v0.12 test test-v.012 install $(wildcard test/test_*.rb) $(wildcard test/**/test_*.rb) benchmark benchmark-remote
.PHONY: run run-td-agent-2.3.5 test test-td-agent-2.3.5 install $(wildcard test/test_*.rb) $(wildcard test/**/test_*.rb) benchmark benchmark-remote

all:
bundle install

run:
bundle exec fluentd -v

run-v0.12:
BUNDLE_GEMFILE=./gemfiles/Gemfile.fluentd-0.12 bundle exec fluentd -v
run-td-agent-2.3.5:
RBENV_VERSION=2.1.10 BUNDLE_GEMFILE=./gemfiles/Gemfile.td-agent-2.3.5 bundle update
RBENV_VERSION=2.1.10 BUNDLE_GEMFILE=./gemfiles/Gemfile.td-agent-2.3.5 bundle exec fluentd -v

test:
bundle exec rake test

test-v.012:
BUNDLE_GEMFILE=./gemfiles/Gemfile.fluentd-0.12 bundle exec rake test
test-td-agent-2.3.5:
RBENV_VERSION=2.1.10 BUNDLE_GEMFILE=./gemfiles/Gemfile.td-agent-2.3.5 bundle update
RBENV_VERSION=2.1.10 BUNDLE_GEMFILE=./gemfiles/Gemfile.td-agent-2.3.5 bundle exec rake test

install:
bundle exec rake install:local
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ To launch `fluentd` process with this plugin for development, follow the steps b

To launch using Fluentd v0.12, use `BUNDLE_GEMFILE` environment variable:

BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.fluentd-0.12 bundle exec fluentd -c /path/to/fluent.conf
BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.td-agent-2.3.5 bundle exec fluentd -c /path/to/fluent.conf

## Contributing

Expand Down
11 changes: 9 additions & 2 deletions fluent-plugin-kinesis.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.1'

spec.add_dependency "fluentd", ">= 0.12.35", "< 2"
spec.add_dependency "aws-sdk-kinesis", "~> 1"
spec.add_dependency "aws-sdk-firehose", "~> 1"
spec.add_dependency "aws-sdk", ">= 2.9.9", "< 4"
# TODO: fluent-plugin-s3 depends on v2 only.
# https://github.com/fluent/fluent-plugin-s3/issues/208
#
# This plugin is sometimes used with s3 plugin.
# Unless s3 plugin is updated to be available with v3,
# this plugin should depend on v2 only.
# spec.add_dependency "aws-sdk-kinesis", "~> 1"
# spec.add_dependency "aws-sdk-firehose", "~> 1"
spec.add_dependency "google-protobuf", "~> 3"

spec.add_development_dependency "bundler", "~> 1.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in fluent-plugin-kinesis.gemspec
gemspec path: ".."

gem "fluentd", ">= 0.12.35", "< 0.14"
# Specify related gems for td-agent v2.3.5
# https://github.com/treasure-data/omnibus-td-agent/blob/release-2.3.5/config/projects/td-agent2.rb#L23
gem "fluentd", "0.12.35"
# https://github.com/treasure-data/omnibus-td-agent/blob/release-2.3.5/plugin_gems.rb#L13-L15
gem "fluent-plugin-s3", "0.8.2"
gem "aws-sdk", "2.9.9"
16 changes: 14 additions & 2 deletions lib/fluent/plugin/kinesis_helper/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,25 @@ def client

private

def aws_sdk_v2?
@aws_sdk_v2 ||= Gem.loaded_specs['aws-sdk-core'].version < Gem::Version.create('3')
end

def client_class
case request_type
when :streams, :streams_aggregated
require 'aws-sdk-kinesis'
if aws_sdk_v2?
require 'aws-sdk'
else
require 'aws-sdk-kinesis'
end
Aws::Kinesis::Client
when :firehose
require 'aws-sdk-firehose'
if aws_sdk_v2?
require 'aws-sdk'
else
require 'aws-sdk-firehose'
end
Aws::Firehose::Client
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
def fluentd_v0_12?
@fluentd_v0_12 ||= Gem.loaded_specs['fluentd'].version < Gem::Version.create('0.14')
end
def aws_sdk_v2?
@aws_sdk_v2 ||= Gem.loaded_specs['aws-sdk-core'].version < Gem::Version.create('3')
end
def driver_run(d, records, time: nil)
time ||= event_time("2011-01-02 13:14:15 UTC")
if fluentd_v0_12?
Expand All @@ -33,6 +36,11 @@ def driver_run(d, records, time: nil)
require 'fluent/test/log'
require 'fluent/test/driver/output'
end
if aws_sdk_v2?
require 'aws-sdk'
else
require 'aws-sdk-firehose'
end
require_relative './dummy_server'
require 'test/unit'
require 'mocha/test_unit'
Expand Down
1 change: 0 additions & 1 deletion test/kinesis_helper/test_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

require_relative '../helper'
require 'fluent/plugin/kinesis_helper/api'
require 'aws-sdk-firehose'

class KinesisHelperAPITest < Test::Unit::TestCase
class Mock
Expand Down
2 changes: 0 additions & 2 deletions test/kinesis_helper/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

require_relative '../helper'
require 'fluent/plugin/kinesis_helper/client'
require 'aws-sdk-core'
require 'aws-sdk-firehose'

class KinesisHelperClientTest < Test::Unit::TestCase
class Mock
Expand Down