Skip to content

Commit a1d0cf6

Browse files
committed
Updated README.md to object-oriented design of API
1 parent bab329e commit a1d0cf6

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
The client API documentation is written in standard Markdown and generated dynamically into C++ headers. You can find the full API overview in [docs/API.md](docs/API.md).
1616

17+
The public API follows the same object-oriented layout as the original Fluvio client: connect with `Fluvio` or `FluvioAdmin`, then call methods on the returned objects.
18+
1719
## Installation
1820

1921
You can install the client effortlessly without compiling the heavy Rust toolchain by using `vcpkg`.
@@ -37,8 +39,8 @@ target_link_libraries(main PRIVATE fluvio_client_cpp::fluvio_client_cpp)
3739
#include "fluvio-client-cpp/src/lib.rs.h"
3840

3941
int main() {
40-
auto admin = fluvio_admin_connect();
41-
admin_create_topic(*admin, "a_topic", 1, 1);
42+
auto admin = FluvioAdmin::connect();
43+
admin->create_topic("a_topic", 1, 1);
4244
return 0;
4345
}
4446
```
@@ -51,18 +53,20 @@ int main() {
5153
#include <string>
5254

5355
int main() {
54-
auto client = fluvio_connect();
55-
auto producer = create_producer(*client, "my-topic");
56+
auto client = Fluvio::connect();
57+
auto producer = client->topic_producer("my-topic");
5658

5759
std::string payload = "FOOBAR";
5860
uint8_t key[] = {};
5961

60-
producer_send(*producer,
62+
auto out = producer->send(
6163
rust::Slice<const uint8_t>(key, 0),
6264
rust::Slice<const uint8_t>(reinterpret_cast<const uint8_t*>(payload.data()), payload.size())
6365
);
6466

65-
producer_flush(*producer);
67+
auto meta = out->wait();
68+
(void)meta;
69+
producer->flush();
6670
return 0;
6771
}
6872
```
@@ -74,16 +78,13 @@ int main() {
7478
#include <iostream>
7579

7680
int main() {
77-
auto client = fluvio_connect();
78-
auto consumer = partition_consumer(*client, "my-topic", 0);
79-
auto stream = consumer_stream(*consumer, 0); // Offset::beginning
81+
auto client = Fluvio::connect();
82+
auto stream = client->consumer_stream("my-topic", 0, 0); // Offset::beginning
8083

81-
for (int i = 0; i < 1; i++) {
82-
auto rec = stream_next(*stream);
83-
auto val = record_value(*rec);
84-
std::string payload(val.begin(), val.end());
85-
std::cout << payload << std::endl;
86-
}
84+
auto rec = stream->next();
85+
auto val = rec->value();
86+
std::string payload(val.begin(), val.end());
87+
std::cout << payload << std::endl;
8788

8889
return 0;
8990
}
@@ -108,4 +109,5 @@ cmake -B build
108109
cmake --build build
109110
cd build
110111
ctest --output-on-failure
112+
cd ..
111113
```

0 commit comments

Comments
 (0)