From 9edc4b93015f2fb1c0d6bb6811f8ed67319e36c1 Mon Sep 17 00:00:00 2001 From: Ben Osheroff Date: Tue, 23 Jun 2015 09:01:31 -0700 Subject: [PATCH] move hermann_lib -> hermann_rdkafka / Hermann::Provider::RDKafka --- Rakefile | 2 +- ext/hermann/hermann_rdkafka.c | 18 +++++++++--------- ext/hermann/hermann_rdkafka.h | 4 ++-- lib/hermann/consumer.rb | 4 ++-- lib/hermann/discovery/metadata.rb | 4 ++-- lib/hermann/producer.rb | 4 ++-- spec/hermann_lib/producer_spec.rb | 6 +++--- spec/producer_spec.rb | 5 +++-- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/Rakefile b/Rakefile index 49bf20c..77aa512 100644 --- a/Rakefile +++ b/Rakefile @@ -6,7 +6,7 @@ require 'rake/extensiontask' Rake::ExtensionTask.new do |t| - t.name = 'hermann_lib' + t.name = 'hermann_rdkafka' t.ext_dir = 'ext/hermann' t.gem_spec = Gem::Specification.load('hermann.gemspec') end diff --git a/ext/hermann/hermann_rdkafka.c b/ext/hermann/hermann_rdkafka.c index 446f2fc..fa747c4 100644 --- a/ext/hermann/hermann_rdkafka.c +++ b/ext/hermann/hermann_rdkafka.c @@ -1,5 +1,5 @@ /* - * hermann_lib.c - Ruby wrapper for the librdkafka library + * hermann_rdkafka.c - Ruby wrapper for the librdkafka library * * Copyright (c) 2014 Stan Campbell * Copyright (c) 2014 Lookout, Inc. @@ -31,7 +31,7 @@ /* Much of the librdkafka library calls were lifted from rdkafka_example.c */ -#include "hermann_lib.h" +#include "hermann_rdkafka.h" #ifdef HAVE_RUBY_VERSION_H #include @@ -444,7 +444,7 @@ static VALUE consumer_consume_loop_stop(VALUE self) { } /** - * Hermann::Lib::Consumer.consume + * Hermann::Provider::RDKafka::Consumer.consume * * @param VALUE self the Ruby object for this consumer * @param VALUE topic the Ruby string representing a topic to consume @@ -1190,21 +1190,21 @@ static VALUE producer_init_copy(VALUE copy, } /** - * Init_hermann_lib + * Init_hermann_rdkafka * * Called by Ruby when the Hermann gem is loaded. * Defines the Hermann module. * Defines the Producer and Consumer classes. */ -void Init_hermann_lib() { - VALUE lib_module, c_consumer, c_producer; +void Init_hermann_rdkafka() { + VALUE lib_module, provider_module, c_consumer, c_producer; - TRACER("setting up Hermann::Lib\n"); + TRACER("setting up Hermann::Provider::RDKafka\n"); /* Define the module */ hermann_module = rb_define_module("Hermann"); - lib_module = rb_define_module_under(hermann_module, "Lib"); - + provider_module = rb_define_module_under(hermann_module, "Provider"); + lib_module = rb_define_module_under(provider_module, "RDKafka"); /* ---- Define the consumer class ---- */ c_consumer = rb_define_class_under(lib_module, "Consumer", rb_cObject); diff --git a/ext/hermann/hermann_rdkafka.h b/ext/hermann/hermann_rdkafka.h index 276ab58..d1c1263 100644 --- a/ext/hermann/hermann_rdkafka.h +++ b/ext/hermann/hermann_rdkafka.h @@ -1,5 +1,5 @@ /* - * hermann_lib.h - Ruby wrapper for the librdkafka library + * hermann_rdkafka.h - Ruby wrapper for the librdkafka library * * Copyright (c) 2014 Stan Campbell * Copyright (c) 2014 Lookout, Inc. @@ -107,7 +107,7 @@ typedef struct HermannInstanceConfig { typedef HermannInstanceConfig hermann_conf_t; typedef struct { - /* Hermann::Lib::Producer */ + /* Hermann::Provider::RDKafka::Producer */ hermann_conf_t *producer; /* Hermann::Result */ VALUE result; diff --git a/lib/hermann/consumer.rb b/lib/hermann/consumer.rb index 4f2fdef..a0fce8e 100644 --- a/lib/hermann/consumer.rb +++ b/lib/hermann/consumer.rb @@ -4,7 +4,7 @@ require 'hermann/errors' if Hermann.jruby? require 'hermann/provider/java_simple_consumer' else - require 'hermann_lib' + require 'hermann_rdkafka' end module Hermann @@ -37,7 +37,7 @@ module Hermann else brokers, partition = require_values_at(opts, :brokers, :partition) - @internal = Hermann::Lib::Consumer.new(topic, brokers, partition, offset) + @internal = Hermann::Provider::RDKafka::Consumer.new(topic, brokers, partition, offset) end end diff --git a/lib/hermann/discovery/metadata.rb b/lib/hermann/discovery/metadata.rb index 96e2e6c..e63197e 100644 --- a/lib/hermann/discovery/metadata.rb +++ b/lib/hermann/discovery/metadata.rb @@ -1,4 +1,4 @@ -require 'hermann_lib' +require 'hermann_rdkafka' require 'hermann/consumer' module Hermann @@ -20,7 +20,7 @@ module Hermann DEFAULT_TIMEOUT_MS = 2_000 def initialize(brokers, options = {}) raise "this is an MRI api only!" if Hermann.jruby? - @internal = Hermann::Lib::Producer.new(brokers) + @internal = Hermann::Provider::RDKafka::Producer.new(brokers) @timeout = options[:timeout] || DEFAULT_TIMEOUT_MS end diff --git a/lib/hermann/producer.rb b/lib/hermann/producer.rb index 911428a..ea722ac 100644 --- a/lib/hermann/producer.rb +++ b/lib/hermann/producer.rb @@ -6,7 +6,7 @@ require 'hermann/result' if RUBY_PLATFORM == "java" require 'hermann/provider/java_producer' else - require 'hermann_lib' + require 'hermann_rdkafka' end module Hermann @@ -23,7 +23,7 @@ module Hermann if Hermann.jruby? @internal = Hermann::Provider::JavaProducer.new(brokers.join(','), opts) else - @internal = Hermann::Lib::Producer.new(brokers.join(',')) + @internal = Hermann::Provider::RDKafka::Producer.new(brokers.join(',')) end # We're tracking children so we can make sure that at Producer exit we # make a reasonable attempt to clean up outstanding result objects diff --git a/spec/hermann_lib/producer_spec.rb b/spec/hermann_lib/producer_spec.rb index 01ab1e1..3d1344f 100644 --- a/spec/hermann_lib/producer_spec.rb +++ b/spec/hermann_lib/producer_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' -describe 'Hermann::Lib::Producer', :platform => :mri do +describe 'Hermann::Provider::RDKafka::Producer', :platform => :mri do before :all do - require 'hermann_lib' + require 'hermann_rdkafka' end let(:topic) { 'rspec' } let(:brokers) { 'localhost:1337' } - subject(:producer) { Hermann::Lib::Producer.new(brokers) } + subject(:producer) { Hermann::Provider::RDKafka::Producer.new(brokers) } let(:timeout) { 3000 } it { should respond_to :push_single } diff --git a/spec/producer_spec.rb b/spec/producer_spec.rb index 95712f3..a5bf34f 100644 --- a/spec/producer_spec.rb +++ b/spec/producer_spec.rb @@ -11,10 +11,11 @@ describe Hermann::Producer do describe '#initialize' do context 'with C ruby', :platform => :mri do it 'joins broker array' do - expect(Hermann::Lib::Producer).to receive(:new).with(brokers.first) + expect(Hermann::Provider::RDKafka::Producer).to receive(:new).with(brokers.first) expect(producer).to be_a Hermann::Producer end end + context 'with Java', :platform => :java do it 'joins broker array' do expect(Hermann::Provider::JavaProducer).to receive(:new).with(brokers.first, opts) @@ -190,7 +191,7 @@ describe Hermann::Producer do describe '#tick_reactor' do let(:timeout) { 0 } - let(:internal) { double('Hermann::Lib::Producer mock') } + let(:internal) { double('Hermann::Provider::RDKafka::Producer mock') } subject(:tick) { producer.tick_reactor(timeout) } before :each do