Coder Social home page Coder Social logo

tisonkun / pulsar-client-cpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apache/pulsar-client-cpp

0.0 0.0 0.0 4.59 MB

Apache Pulsar C++ client library

Home Page: https://pulsar.apache.org/

License: Apache License 2.0

Shell 1.85% C++ 92.27% Python 0.33% C 3.12% CMake 1.35% Dockerfile 0.92% Roff 0.16%

pulsar-client-cpp's Introduction

Pulsar C++ client library

Examples for using the API to publish and consume messages can be found on https://github.com/apache/pulsar/tree/master/pulsar-client-cpp/examples

Requirements

It's recommended to use Protocol Buffer 2.6 because it's verified by CI, but 3.x also works.

The default supported compression types are:

  • CompressionNone
  • CompressionLZ4

If you want to enable other compression types, you need to install:

  • CompressionZLib: zlib
  • CompressionZSTD: zstd
  • CompressionSNAPPY: snappy

If you want to build and run the tests, you need to install GTest. Otherwise, you need to add CMake option -DBUILD_TESTS=OFF.

If you don't want to build Python client since boost-python may not be easy to install, you need to add CMake option -DBUILD_PYTHON_WRAPPER=OFF.

If you want to use ClientConfiguration::setLogConfFilePath, you need to install the Log4CXX and add CMake option -DUSE_LOG4CXX=ON.

Platforms

Pulsar C++ Client Library has been tested on:

  • Linux
  • Mac OS X
  • Windows x64

Compilation

Compile on Ubuntu

Install all dependencies:

sudo apt-get install -y g++ cmake libssl-dev libcurl4-openssl-dev \
                libprotobuf-dev libboost-all-dev libgtest-dev libgmock-dev \
                protobuf-compiler

Compile Pulsar client library:

cd pulsar-client-cpp
cmake .
make

Checks

Client library will be placed in
lib/libpulsar.so
lib/libpulsar.a
Tools will be placed in
perf/perfProducer
perf/perfConsumer

Compile on Mac OS X

Install all dependencies:

brew install openssl protobuf boost boost-python3 googletest zstd snappy

Compile Pulsar client library:

cd pulsar-client-cpp/
cmake .
make

Checks

Client library will be placed in
lib/libpulsar.dylib
lib/libpulsar.a
Tools will be placed in:
perf/perfProducer
perf/perfConsumer

Compile on Windows

Install with vcpkg

It's highly recommended to use vcpkg for C++ package management on Windows. It's easy to install and well supported by Visual Studio (2015/2017/2019) and CMake. See here for quick start.

Take Windows 64-bit library as an example, you only need to run

vcpkg install --feature-flags=manifests --triplet x64-windows

NOTE: For Windows 32-bit library, change x64-windows to x86-windows, see here for more details about the triplet concept in Vcpkg.

The all dependencies, which are specified by vcpkg.json, will be installed in vcpkg_installed/ subdirectory,

With vcpkg, you only need to run two commands:

cmake \
 -B ./build \
 -A x64 \
 -DBUILD_PYTHON_WRAPPER=OFF -DBUILD_TESTS=OFF \
 -DVCPKG_TRIPLET=x64-windows \
 -DCMAKE_BUILD_TYPE=Release \
 -S .
cmake --build ./build --config Release

Then all artifacts will be built into build subdirectory.

NOTE

  1. For Windows 32-bit, you need to use -A Win32 and -DVCPKG_TRIPLET=x86-windows.
  2. For MSVC Debug mode, you need to replace Release with Debug for both CMAKE_BUILD_TYPE variable and --config option.

Install dependencies manually

You need to install dlfcn-win32 in addition.

If you installed the dependencies manually, you need to run

#If all dependencies are in your path, all that is necessary is
pulsar-client-cpp/cmake .

#if all dependencies are not in your path, then passing in a PROTOC_PATH and CMAKE_PREFIX_PATH is necessary
pulsar-client-cpp/cmake -DPROTOC_PATH=C:/protobuf/bin/protoc -DCMAKE_PREFIX_PATH="C:/boost;C:/openssl;C:/zlib;C:/curl;C:/protobuf;C:/googletest;C:/dlfcn-win32" .

#This will generate pulsar-cpp.sln. Open this in Visual Studio and build the desired configurations.

Checks

Client libraries are available in the following places.
pulsar-client-cpp/build/lib/Release/pulsar.lib
pulsar-client-cpp/build/lib/Release/pulsar.dll

Examples

Add windows environment paths.
pulsar-client-cpp/build/lib/Release
pulsar-client-cpp/vcpkg_installed
Examples are available in.
pulsar-client-cpp/build/examples/Release

Tests

# Execution
# Start standalone broker
./pulsar-test-service-start.sh

# Run the tests
cd tests
./pulsar-tests

# When no longer needed, stop standalone broker
./pulsar-test-service-stop.sh

Requirements for Contributors

It's required to install LLVM for clang-tidy and clang-format. Pulsar C++ client use clang-format 11 to format files. make format automatically formats the files.

For Ubuntu users, you can install clang-format-11 via apt install clang-format-11. For other users, run ./build-support/docker-format.sh if you have Docker installed.

We welcome contributions from the open source community, kindly make sure your changes are backward compatible with GCC 4.8 and Boost 1.53.

pulsar-client-cpp's People

Contributors

merlimat avatar bewaremypower avatar jai1 avatar demogorgon314 avatar jiazhai avatar sijie avatar aahmed-se avatar srkukarni avatar wolfstudy avatar robertindie avatar rdhabalia avatar zhaijack avatar ivankelly avatar licht-t avatar hrsakai avatar gaoran10 avatar k2la avatar tuteng avatar zymap avatar candlerb avatar jerrypeng avatar lucperkins avatar congbobo184 avatar coderzc avatar lovelle avatar lhotari avatar codelipenghui avatar saandrews avatar michaeljmarshall avatar saosir avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.