Skip to content

Commit

Permalink
Develop cpp (#762)
Browse files Browse the repository at this point in the history
* feat: add tagged-release github action pipeline

Signed-off-by: Zhanhui Li <lizhanhui@gmail.com>

* Fix C++ SDK core dump issue (#2)

* fix: sync namespace from server Settings

* feat: use opentelemetry for tracing/metrics/logging

* Remove broken links and add targets to generate compile_commands.json

Signed-off-by: lizhanhui <lizhanhui@gmail.com>

* fix: timer task may invoke a call to a destructing stream

Signed-off-by: Zhanhui Li <lizhanhui@gmail.com>

* fix: update document as we have changed the way to generate compile_commands.json

* fix: static_cast StreamState to std::uint8_t as enum class by default is not formattable

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

---------

Signed-off-by: lizhanhui <lizhanhui@gmail.com>
Signed-off-by: Zhanhui Li <lizhanhui@gmail.com>
Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: fix stream state transition with gRPC reactor

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: revamp TelemetryBidiRecator

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* feat: explicitly control exported symbols

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: release write hold when OnReadDone with ok=false and there is no inflight write

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* feat: revamp TelemetryBidiReactor states and their transition graph

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: example publish message QPS stats lambda

* Fifo opt (#732)

* Prepare to optimize FIFO publishing

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: SendReceipt now contains std::unique_ptr<Message> being sent

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: add doc explaining why we taking ownership of the message being sent

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* feat: implement FifoProducerPartition

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* feat: implement FifoProducerImpl

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* feat: implement builder for FifoProducer

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: prepare to debug

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: log sending sending stages

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

---------

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: spell errors

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: markdown code blocks should be fenced by blank lines

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: copyright header

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: copyright header

Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>

* fix: include statements

Signed-off-by: Zhanhui Li <lizhanhui@gmail.com>

* feat: build example_fifo_producer in BUILD.bazel

Signed-off-by: Zhanhui Li <lizhanhui@gmail.com>

* fix: #713 correct misuse of absl::make_optional

Signed-off-by: Zhanhui Li <lizhanhui@gmail.com>

---------

Signed-off-by: Zhanhui Li <lizhanhui@gmail.com>
Signed-off-by: lizhanhui <lizhanhui@gmail.com>
Signed-off-by: Li Zhanhui <lizhanhui@gmail.com>
  • Loading branch information
lizhanhui committed Jun 26, 2024
1 parent ad13fe3 commit 156784b
Show file tree
Hide file tree
Showing 51 changed files with 1,537 additions and 344 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/cpp_tagged_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: "cpp-tagged-release"

on:
push:
tags:
- "cpp-*"

jobs:
tagged-release:
name: "C++ Tagged Release"
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: grpc/grpc
# The branch, tag or SHA to checkout. When checking out the repository that
# triggered a workflow, this defaults to the reference or SHA for that event.
# Otherwise, uses the default branch.
ref: 'v1.46.3'
# Relative path under $GITHUB_WORKSPACE to place the repository
path: cpp/repo/grpc
submodules: true
- name: "Install Dependencies"
run: |
sudo apt-get install -y build-essential autoconf libtool pkg-config cmake git libprotobuf-dev libssl-dev zlib1g-dev libgflags-dev
- name: "Build gRPC"
working-directory: ./cpp/repo/grpc
run: |
mkdir _build && cd _build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/grpc -DgRPC_SSL_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG -DgRPC_ZLIB_PROVIDER=package ..
make
make install
- name: "Build Libraries"
working-directory: ./cpp
run: |
mkdir _build && cd _build
cmake ..
make
- name: "Package"
working-directory: ./cpp
run: |
mkdir -p dist/lib
mkdir -p dist/include
cp -r include/rocketmq dist/include/
cp _build/librocketmq.so dist/lib/
cp _build/librocketmq.a dist/lib/
tar -czvf dist.tar.gz dist
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: cpp
files: |
cpp/dist.tar.gz
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ header:
- 'cpp/.gitignore'
- 'cpp/third_party'
- 'cpp/cmake'
- 'cpp/source/exports.map'
- 'php/grpc/**/*.php'
- 'php/composer.json'
- 'rust/.cargo/Cargo.lock.min'
Expand Down
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.19)
cmake_minimum_required(VERSION 3.16)
project(rocketmq)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down Expand Up @@ -31,4 +31,4 @@ if (BUILD_EXAMPLES)
find_package(gflags REQUIRED)
find_package(ZLIB REQUIRED)
add_subdirectory(examples)
endif ()
endif ()
23 changes: 12 additions & 11 deletions cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,13 @@ if "com_google_googletest" not in native.existing_rules():
1. VSCode + Clangd

[Clangd](https://clangd.llvm.org/) is a really nice code completion tool. Clangd requires compile_commands.json to work properly.
To generate the file, we need clone another repository along with the current one.
To generate the file, run the following command:

```sh
git clone git@github.com:grailbio/bazel-compilation-database.git
./tools/gen_compile_commands.sh
```

From current repository root,

```sh
../bazel-compilation-database/generate.sh
```

Once the script completes, you should have compile_commands.json file in the repository root directory.
Once the script completes, you should have compile_commands.json file in the workspace directory, aka, ${repository}/cpp.

LLVM project has an extension for [clangd](https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd). Please install it from the extension market.

Expand All @@ -239,8 +233,15 @@ if "com_google_googletest" not in native.existing_rules():
"C_Cpp.intelliSenseEngine": "Disabled",
"C_Cpp.autocomplete": "Disabled", // So you don't get autocomplete from both extensions.
"C_Cpp.errorSquiggles": "Disabled", // So you don't get error squiggles from both extensions (clangd's seem to be more reliable anyway).
"clangd.path": "/Users/lizhanhui/usr/clangd_12.0.0/bin/clangd",
"clangd.arguments": ["-log=verbose", "-pretty", "--background-index"],
"clangd.path": "/usr/bin/clangd",
"clangd.arguments": [
"-log=verbose",
"-pretty",
"--background-index",
"--header-insertion=never",
"--compile-commands-dir=${workspaceFolder}/",
"--query-driver=**"
],
"clangd.onConfigChanged": "restart",
```

Expand Down
26 changes: 25 additions & 1 deletion cpp/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,28 @@ http_archive(
load("@io_buildbuddy_buildbuddy_toolchain//:deps.bzl", "buildbuddy_deps")
buildbuddy_deps()
load("@io_buildbuddy_buildbuddy_toolchain//:rules.bzl", "buildbuddy")
buildbuddy(name = "buildbuddy_toolchain")
buildbuddy(name = "buildbuddy_toolchain")

# Generate compile_commands.json
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")


# Hedron's Compile Commands Extractor for Bazel
# https://github.com/hedronvision/bazel-compile-commands-extractor
http_archive(
name = "hedron_compile_commands",

# Replace the commit hash (0e990032f3c5a866e72615cf67e5ce22186dcb97) in both places (below) with the latest (https://github.com/hedronvision/bazel-compile-commands-extractor/commits/main), rather than using the stale one here.
# Even better, set up Renovate and let it do the work for you (see "Suggestion: Updates" in the README).
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/204aa593e002cbd177d30f11f54cff3559110bb9.tar.gz",
strip_prefix = "bazel-compile-commands-extractor-204aa593e002cbd177d30f11f54cff3559110bb9",
# When you first run this tool, it'll recommend a sha256 hash to put here with a message like: "DEBUG: Rule 'hedron_compile_commands' indicated that a canonical reproducible form can be obtained by modifying arguments sha256 = ..."
)
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")
hedron_compile_commands_setup()
load("@hedron_compile_commands//:workspace_setup_transitive.bzl", "hedron_compile_commands_setup_transitive")
hedron_compile_commands_setup_transitive()
load("@hedron_compile_commands//:workspace_setup_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive")
hedron_compile_commands_setup_transitive_transitive()
load("@hedron_compile_commands//:workspace_setup_transitive_transitive_transitive.bzl", "hedron_compile_commands_setup_transitive_transitive_transitive")
hedron_compile_commands_setup_transitive_transitive_transitive()
25 changes: 9 additions & 16 deletions cpp/bazel/rocketmq_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def rocketmq_deps():
sha256 = "b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5",
strip_prefix = "googletest-release-1.11.0",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/googletest/googletest-release-1.11.0.tar.gz",
"https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz",
],
)
Expand All @@ -27,7 +26,6 @@ def rocketmq_deps():
strip_prefix = "filesystem-1.5.0",
sha256 = "eb6f3b0739908ad839cde68885d70e7324db191b9fad63d9915beaa40444d9cb",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/filesystem/filesystem-1.5.0.tar.gz",
"https://github.com/gulrak/filesystem/archive/v1.5.0.tar.gz",
],
build_file = "@org_apache_rocketmq//third_party:filesystem.BUILD",
Expand All @@ -39,7 +37,6 @@ def rocketmq_deps():
strip_prefix = "spdlog-1.9.2",
sha256 = "6fff9215f5cb81760be4cc16d033526d1080427d236e86d70bb02994f85e3d38",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/spdlog/spdlog-1.9.2.tar.gz",
"https://github.com/gabime/spdlog/archive/refs/tags/v1.9.2.tar.gz",
],
build_file = "@org_apache_rocketmq//third_party:spdlog.BUILD",
Expand All @@ -51,7 +48,6 @@ def rocketmq_deps():
strip_prefix = "fmt-8.0.1",
sha256 = "b06ca3130158c625848f3fb7418f235155a4d389b2abc3a6245fb01cb0eb1e01",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/fmt/fmt-8.0.1.tar.gz",
"https://github.com/fmtlib/fmt/archive/refs/tags/8.0.1.tar.gz",
],
build_file = "@org_apache_rocketmq//third_party:fmtlib.BUILD",
Expand All @@ -63,7 +59,6 @@ def rocketmq_deps():
sha256 = "8b28fdd45bab62d15db232ec404248901842e5340299a57765e48abe8a80d930",
strip_prefix = "protobuf-3.20.1",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/protobuf/protobuf-3.20.1.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.20.1.tar.gz",
],
)
Expand All @@ -74,7 +69,6 @@ def rocketmq_deps():
sha256 = "507e38c8d95c7efa4f3b1c0595a8e8f139c885cb41a76cab7e20e4e67ae87731",
strip_prefix = "rules_proto_grpc-4.1.1",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/rules_proto_grpc/rules_proto_grpc-4.1.1.tar.gz",
"https://github.com/rules-proto-grpc/rules_proto_grpc/archive/refs/tags/4.1.1.tar.gz",
],
)
Expand All @@ -84,7 +78,6 @@ def rocketmq_deps():
name = "io_opencensus_cpp",
sha256 = "317f2bfdaba469561c7e64b1a55282b87e677c109c9d8877097940e6d5cbca08",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/opencensus-cpp/opencensus-cpp-0.4.1.tar.gz",
"https://github.com/lizhanhui/opencensus-cpp/archive/refs/tags/v0.4.1.tar.gz",
],
strip_prefix = "opencensus-cpp-0.4.1",
Expand All @@ -96,7 +89,6 @@ def rocketmq_deps():
sha256 = "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
strip_prefix = "abseil-cpp-20211102.0",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/abseil/abseil-cpp-20211102.0.tar.gz",
"https://github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
],
)
Expand All @@ -107,7 +99,6 @@ def rocketmq_deps():
strip_prefix = "gflags-2.2.2",
sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/gflags/gflags-2.2.2.tar.gz",
"https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz",
],
)
Expand All @@ -118,7 +109,6 @@ def rocketmq_deps():
strip_prefix = "grpc-1.46.3",
sha256 = "d6cbf22cb5007af71b61c6be316a79397469c58c82a942552a62e708bce60964",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/grpc/grpc-1.46.3.tar.gz",
"https://github.com/grpc/grpc/archive/refs/tags/v1.46.3.tar.gz",
],
)
Expand All @@ -130,7 +120,6 @@ def rocketmq_deps():
build_file = "@org_apache_rocketmq//third_party:asio.BUILD",
strip_prefix = "asio-1.18.2",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/asio/asio-1.18.2.tar.gz",
"https://github.com/lizhanhui/asio/archive/refs/tags/v1.18.2.tar.gz",
],
)
Expand All @@ -140,7 +129,6 @@ def rocketmq_deps():
name = "com_google_googleapis",
sha256 = "e89f15d54b0ddab0cd41d18cb2299e5447db704e2b05ff141cb1769170671466",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/googleapis/googleapis-af7fb72df59a814221b123a4d1acb3f6c3e6cc95.zip",
"https://github.com/googleapis/googleapis/archive/af7fb72df59a814221b123a4d1acb3f6c3e6cc95.zip",
],
strip_prefix = "googleapis-af7fb72df59a814221b123a4d1acb3f6c3e6cc95",
Expand All @@ -152,7 +140,6 @@ def rocketmq_deps():
sha256 = "cdf6b84084aad8f10bf20b46b77cb48d83c319ebe6458a18e9d2cebf57807cdd",
strip_prefix = "rules_python-0.8.1",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/rules-python/rules_python-0.8.1.tar.gz",
"https://github.com/bazelbuild/rules_python/archive/refs/tags/0.8.1.tar.gz",
],
)
Expand All @@ -161,7 +148,6 @@ def rocketmq_deps():
http_archive,
name = "rules_swift",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/rules_swift/rules_swift-0.27.0.tar.gz",
"https://github.com/bazelbuild/rules_swift/archive/refs/tags/0.27.0.tar.gz",
],
strip_prefix = "rules_swift-0.27.0",
Expand All @@ -172,7 +158,6 @@ def rocketmq_deps():
name = "io_bazel_rules_go",
sha256 = "685052b498b6ddfe562ca7a97736741d87916fe536623afb7da2824c0211c369",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/rules-go/rules_go-v0.33.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.33.0/rules_go-v0.33.0.zip",
],
Expand All @@ -184,7 +169,15 @@ def rocketmq_deps():
sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
strip_prefix = "rules_proto-4.0.0-3.20.0",
urls = [
"https://shutian.oss-cn-hangzhou.aliyuncs.com/cdn/rules_proto/rules_proto-4.0.0-3.20.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0-3.20.0.tar.gz",
],
)

maybe(
http_archive,
name = "com_github_opentelemetry",
strip_prefix = "opentelemetry-cpp-1.14.2",
urls = [
"https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.14.2.tar.gz"
]
)
11 changes: 11 additions & 0 deletions cpp/examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,15 @@ cc_binary(
"//source/rocketmq:rocketmq_library",
"@com_github_gflags_gflags//:gflags",
],
)

cc_binary(
name = "example_fifo_producer",
srcs = [
"ExampleFifoProducer.cpp",
],
deps = [
"//source/rocketmq:rocketmq_library",
"@com_github_gflags_gflags//:gflags",
]
)
1 change: 1 addition & 0 deletions cpp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function(add_example name file)
endfunction()

add_example(example_producer ExampleProducer.cpp)
add_example(example_fifo_producer ExampleFifoProducer.cpp)
add_example(example_producer_with_async ExampleProducerWithAsync.cpp)
add_example(example_producer_with_fifo_message ExampleProducerWithFifoMessage.cpp)
add_example(example_producer_with_timed_message ExampleProducerWithTimedMessage.cpp)
Expand Down
Loading

0 comments on commit 156784b

Please sign in to comment.