diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index a7f6bd7..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..aafc22f --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,26 @@ +PATH + remote: . + specs: + leffen-kafka-rb (0.0.15) + +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.2.2) + rake (10.0.4) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.1) + +PLATFORMS + ruby + +DEPENDENCIES + leffen-kafka-rb! + rake + rspec diff --git a/Rakefile b/Rakefile index 7182732..9d54629 100644 --- a/Rakefile +++ b/Rakefile @@ -19,7 +19,7 @@ require 'rubygems/specification' require 'date' require 'rspec/core/rake_task' -spec = eval(File.open("kafka-rb.gemspec", "r").read) +spec = eval(File.open("leffen-kafka-rb.gemspec", "r").read) Gem::PackageTask.new(spec) do |pkg| pkg.gem_spec = spec diff --git a/bin/kafka-consumer b/bin/leffen-kafka-consumer similarity index 100% rename from bin/kafka-consumer rename to bin/leffen-kafka-consumer diff --git a/bin/kafka-publish b/bin/leffen-kafka-publish similarity index 100% rename from bin/kafka-publish rename to bin/leffen-kafka-publish diff --git a/leffen-kafka-rb-0.0.15.gem b/leffen-kafka-rb-0.0.15.gem new file mode 100644 index 0000000..1394680 Binary files /dev/null and b/leffen-kafka-rb-0.0.15.gem differ diff --git a/kafka-rb.gemspec b/leffen-kafka-rb.gemspec similarity index 84% rename from kafka-rb.gemspec rename to leffen-kafka-rb.gemspec index 38e57bd..7050ef6 100644 --- a/kafka-rb.gemspec +++ b/leffen-kafka-rb.gemspec @@ -1,10 +1,11 @@ Gem::Specification.new do |s| - s.name = %q{kafka-rb} + s.name = %q{leffen-kafka-rb} s.version = "0.0.15" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Alejandro Crosa", "Stefan Mees", "Tim Lossen", "Liam Stewart"] - s.autorequire = %q{kafka-rb} + s.email = 'leffen@gmail.com' + s.homepage = 'http://tomlea.co.uk/p/gem-in-a-box' s.date = Time.now.strftime("%Y-%m-%d") s.description = %q{kafka-rb allows you to produce and consume messages using the Kafka distributed publish/subscribe messaging service.} s.extra_rdoc_files = ["LICENSE"] @@ -13,7 +14,7 @@ Gem::Specification.new do |s| s.homepage = %q{http://github.com/acrosa/kafka-rb} s.require_paths = ["lib"] s.summary = %q{A Ruby client for the Kafka distributed publish/subscribe messaging service} - s.executables = ["kafka-consumer", "kafka-publish"] + s.executables = ["leffen-kafka-consumer", "leffen-kafka-publish"] if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION diff --git a/lib/kafka/cli.rb b/lib/kafka/cli.rb index 24005b2..b43f873 100644 --- a/lib/kafka/cli.rb +++ b/lib/kafka/cli.rb @@ -109,7 +109,7 @@ def option_parser end def publish? - program_name == "kafka-publish" + program_name == "leffen-kafka-publish" end def subscribe? diff --git a/lib/kafka/consumer.rb b/lib/kafka/consumer.rb index bba8229..aa440c9 100644 --- a/lib/kafka/consumer.rb +++ b/lib/kafka/consumer.rb @@ -57,13 +57,18 @@ def consume end def fetch_latest_offset - send_offsets_request + send_offsets_request(LATEST_OFFSET) read_offsets_response end - def send_offsets_request + def fetch_earliest_offset + send_offsets_request(EARLIEST_OFFSET) + read_offsets_response + end + + def send_offsets_request(offset) write(encoded_request_size) - write(encode_request(Kafka::RequestType::OFFSETS, topic, partition, LATEST_OFFSET, MAX_OFFSETS)) + write(encode_request(Kafka::RequestType::OFFSETS, topic, partition, offset, MAX_OFFSETS)) end def read_offsets_response diff --git a/lib/leffen-kafka.rb b/lib/leffen-kafka.rb new file mode 100644 index 0000000..a7a08f5 --- /dev/null +++ b/lib/leffen-kafka.rb @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require File.join(File.dirname(__FILE__), "kafka")