From 0c42292dbe65980d14cbb5bb3d7d0c025e1aeb7c Mon Sep 17 00:00:00 2001 From: StarostaGit Date: Sat, 27 Jun 2020 23:41:58 +0200 Subject: [PATCH] Expanded README Added building instructions and example usage to README.md --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 81327a9..3de9a20 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,45 @@ # seastar-kafka-client A Kafka client library for Seastar applications + +## Building +To build seastar-kafka-client as a standalone library simply run the following commands: +```bash +$ mkdir build/release +$ cd build/release +$ cmake -DCMAKE_BUILD_TYPE=Release ../.. +$ make +``` + +Additionally, if you want to install the library, run `sudo make install`. + +Seastar-kafka-client uses Seastar and will try to find it installed on the machine. +If you wnat to provide the path manually you can set the following cmake cached variables: +* `CMAKE_PATH_PREFIX` to `/path/to/seastar/build/release` +* `CMAKE_MODULE_PREFIX` to `/path/to/seastar/cmake` + +## Usage +Example usage of the producer client is shown in `demo/kafka_demo.cc`. Generally, it should +look like this: +```cpp +#include + +namespace k4s = kafka4seastar; + +# setup the producer +k4s::producer_properties properties; +properties.client_id = "client-id"; + +# list of servers to establish a starting connection with +properties.servers = { + {host, port} // for example {"172.13.0.1", 9092} +}; + +k4s::kafka_producer producer(std::move(properties)); +producer.init().wait(); + +# scheduling the message for production +producer.produce("topic", "key", "value"); + +# ending work with producer +producer.disconnect().wait(); +``` \ No newline at end of file