rafka-rb: Ruby driver for Rafka

Gem Version Documentation

rafka-rb is a Ruby client for Rafka, providing consumer and producer implementations with simple semantics. It is backed by redis-rb.

Refer to the API documentation for more information.

Features

  • Consumer implementation
    • consumer groups
    • offsets are managed automatically
  • Producer implementation
    • 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!")

See the API documentation of Producer for more information.

Consumer

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

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

See the API documentation of Consumer for more information.

Testing

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