ruby-kafka

https://github.com/zendesk/ruby-kafka

Ruby

A Ruby client library for Apache Kafka

Kafka::Producer#produce

Produces a message to the specified topic. Note that messages are buffered in
the producer until {#deliver_messages} is called.

## Partitioning

There are several options for specifying the partition that the message should
be written to.

The simplest option is to not specify a message key, partition key, or
partition number, in which case the message will be assigned a partition at
random.

You can also specify the `partition` parameter yourself. This requires you to
know which partitions are available, however. Oftentimes the best option is
to specify the `partition_key` parameter: messages with the same partition
key will always be assigned to the same partition, as long as the number of
partitions doesn't change. You can also omit the partition key and specify
a message key instead. The message key is part of the message payload, and
so can carry semantic value--whether you want to have the message key double
as a partition key is up to you.

Source | Google | Stack overflow

Edit

git clone [email protected]:zendesk/ruby-kafka.git

cd ruby-kafka

open lib/kafka/producer.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-Kafka--Producer-produce-for-pr


# Commit to git

git add lib/kafka/producer.rbgit commit -m "better docs for Kafka::Producer#produce"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-Kafka--Producer-produce-for-pr

hub pull-request


# Celebrate!