Giter Club home page Giter Club logo

rafka-rb's Introduction

rafka-rb

Build Status Gem Version Documentation

rafka-rb is a Ruby client library for Rafka, providing Consumer and Producer implementations with simple semantics.

Refer to the API documentation for more information.

Features

  • Consumer
    • consumer groups
    • support for consuming in batches
    • offsets may be managed automatically or manually
  • Producer
    • support for partition hashing key

Getting started

Install rafka-rb:

$ gem install rafka

If you're using Bundler, add it to your Gemfile:

gem "rafka"

and run bundle install.

Usage

Producer

producer = Rafka::Producer.new(host: "localhost", port: 6380)
producer.produce("greetings", "Hello there!")

Refer to the Producer API documentation for more information.

Consumer

consumer = Rafka::Consumer.new(topic: "greetings", group: "myapp")
msg = consumer.consume
msg.value # => "Hello there!"

# with a block
consumer.consume { |msg| puts "Received: #{msg.value}" } # => "Hello there!"

Offsets are managed automatically by default. If you need more control you can turn off the feature and manually commit offsets:

consumer = Rafka::Consumer.new(topic: "greetings", group: "myapp", auto_commit: false)

# commit a single offset
msg = consumer.consume
consumer.commit(msg) # => true

# or commit a bunch of offsets
msg1 = consumer.consume
msg2 = consumer.consume
consumer.commit(msg1, msg2) # => true

Consumers may also set their own custom librdkafka configuration:

consumer = Rafka::Consumer.new(
  topic: "greetings", group: "myapp", librdkafka: { "auto.offset.reset" => "earliest" }
)

Refer to the Consumer API documentation for more information.

Development

Running Rubocop:

$ bundle exec rake rubocop

Unit tests run as follows:

$ bundle exec rake test

rafka-rb is indirectly tested by Rafka's end-to-end tests.

License

rafka-rb is released under the GNU General Public License version 3. See COPYING.

rafka-rb's People

Contributors

agis avatar avgerin0s avatar charkost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rafka-rb's Issues

Server shutdown errors should be retriable

When rafka is in the process of shutting down and it receives a command for a new consumer or producer, it returns a "shutdown" error to the client.

rafka-rb now exits upon such an error. Howevever, these kinds of errors should be retriable, since they indicate that probably the server is restarting (i.e. during an upgrade).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.