rafka-rb: Ruby driver for Rafka
Rafka is a thin Ruby client library for Rafka, providing a consumer and a producer with simple semantics. It is backed by redis-rb.
View the API documentation.
Status
Rafka is not yet stable and therefore is not recommended for production use.
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
require "rafka"
prod = Rafka::Producer.new(host: "localhost", port: 6380)
prod.produce("greetings", "Hello there!") # produce to topic "greetings"
Consumer
require "rafka"
cons = Rafka::Consumer.new(topic: "greetings", group: "myapp", id: "greeter1")
cons.consume # => "Hello there!"
# with a block
cons.consume { |msg| puts "Received: #{msg.value}" } # => "Hello there!"
Rafka::Consumer#consume automatically commits the offsets when the given block
is executed without raising any exceptions.