Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][doc] Add documents for C++ client 3.0.0 or later #18574

Merged
merged 6 commits into from
Nov 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion site2/docs/client-libraries-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,41 @@ import TabItem from '@theme/TabItem';

You can use a Pulsar C++ client to create producers, consumers, and readers. For Pulsar features that C++ clients support, see [Client Feature Matrix](https://docs.google.com/spreadsheets/d/1YHYTkIXR8-Ql103u-IMI18TXLlGStK8uJjDsOOA0T20/edit#gid=1784579914). For complete examples, refer to [C++ client examples](https://github.com/apache/pulsar-client-cpp/tree/main/examples).

## Version 3.0.0 or later
BewareMyPower marked this conversation as resolved.
Show resolved Hide resolved

The version of the Pulsar C++ client is no longer consistent with Pulsar after 2.10.x. The new client version starts from 3.0.0. You can turn to [the download page](https://pulsar.apache.org/download) to see the latest releases.
BewareMyPower marked this conversation as resolved.
Show resolved Hide resolved

Take the [3.0.0 release](https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.0.0/) for example, there are following subdirectories:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After 3.0, do we no longer support brew install?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still support brew install, see Homebrew/homebrew-core#114737

- apk-arm64: the Alpine Linux packages for ARM64 architectures
- apk-x86_64: the Alpine Linux packages for x64 architectures
- deb-arm64: the Debian-based Linux packages for ARM64 architectures
- deb-x86_64: the Debian-based Linux packages for x64 architectures
- rpm-arm64: the RedHat-based Linux packages for ARM64 architectures
- rpm-x86_64: the RedHat-based Linux packages for x64 architectures

These Linux packages above all contain the C++ headers installed under `/usr/include` and the following libraries installed under `/usr/lib`:
- libpulsar.so: the shared library that links 3rd party dependencies statically
- libpulsar.a: the static library
- libpulsarwithdeps.a: the fat static library that includes all 3rd party dependencies

Here is an example to link these libraries for a C++ source file named `main.cc`:

```bash
# Link to libpulsar.so
g++ -std=c++11 main.cc -lpulsar
# Link to libpulsarwithdeps.a
g++ -std=c++11 main.cc /usr/lib/libpulsarwithdeps.a -lpthread -ldl
# Link to libpulsar.a
g++ -std=c++11 main.cc /usr/lib/libpulsar.a \
-lprotobuf -lcurl -lssl -lcrypto -lz -lzstd -lsnappy -lpthread -ldl
```

> **NOTE**
>
> Linking to `libpulsar.a` might be difficult for beginners because the 3rd party dependencies must be compatible. For example, the protobuf version must be 3.20.0 or higher for Pulsar C++ client 3.0.0. It's better to link to `libpulsarwithdeps.a` instead.
>
BewareMyPower marked this conversation as resolved.
Show resolved Hide resolved
> Before 3.0.0, there was a `libpulsarnossl.so`, which is removed now.
BewareMyPower marked this conversation as resolved.
Show resolved Hide resolved

## Installation

Use one of the following methods to install a Pulsar C++ client.
Expand Down Expand Up @@ -104,6 +139,13 @@ If you get an error like "libpulsar.so: cannot open shared object file: No such

:::

### APK

```bash
apk add --allow-untrusted ./apache-pulsar-client-3.0.0-r0.apk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we stick to 3.0.0 in the document here? If so, you may update the links above for other hard linked items (RPM, DEB).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use apache-pulsar-client-*.apk instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it seems to me that -r0 referred to a release candidate, is it a formal release?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apk add --allow-untrusted ./apache-pulsar-client-dev-3.0.0-r0.apk
```

## Connection URLs

To connect to Pulsar using client libraries, you need to specify a [Pulsar protocol](developing-binary-protocol.md) URL.
Expand Down Expand Up @@ -398,4 +440,4 @@ client.subscribe("my-topic", "my-sub", conf, consumer);

## Schema

To work with [Pulsar schema](schema-overview.md) using C++ clients, see [Schema - Get started](schema-get-started.md). For specific schema types that C++ clients support, see [code](https://github.com/apache/pulsar-client-cpp/blob/main/include/pulsar/Schema.h).
To work with [Pulsar schema](schema-overview.md) using C++ clients, see [Schema - Get started](schema-get-started.md). For specific schema types that C++ clients support, see [code](https://github.com/apache/pulsar-client-cpp/blob/main/include/pulsar/Schema.h).