-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added building instructions and example usage to README.md
- Loading branch information
1 parent
ca2b8e7
commit d3562e3
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <kafka4seastar/producer/kafka_producer> | ||
|
||
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(); | ||
``` |