Merge pull request #118 from zendesk/namespace

REFACTOR ONLY: Namespace cleanup
This commit is contained in:
R. Tyler Croy 2015-06-27 11:04:23 -07:00
commit 60bc473fdd
9 changed files with 25 additions and 24 deletions

View File

@ -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

View File

@ -151,4 +151,4 @@ have_header('ruby/version.h')
have_func('rb_thread_blocking_region')
have_func('rb_thread_call_without_gvl')
create_makefile('hermann/hermann_lib')
create_makefile('hermann/hermann_rdkafka')

View File

@ -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 <ruby/version.h>
@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 }

View File

@ -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