diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index b130908..969e8bc 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -51,5 +51,9 @@ updates:
interval: "daily"
- package-ecosystem: "pub"
directory: "hello_grpc_flutter"
+ schedule:
+ interval: "daily"
+ - package-ecosystem: "bazel"
+ directory: "hello-grpc-cpp"
schedule:
interval: "daily"
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 8120663..c337311 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,9 +77,13 @@ docker/glog
docker/gflags
docker/Catch2
bazel-*
-hello_grpc_flutter/build/*
+.clwb
+# flutter
+hello_grpc_flutter/build/*
+# kotlin
hello-grpc-kotlin/client/build
hello-grpc-kotlin/server/build
hello-grpc-kotlin/stub/build
hello-grpc-kotlin/protos/build
+
diff --git a/diagram/build_tools.zip b/diagram/build_tools.zip
index cb83a6e..408dd5b 100644
Binary files a/diagram/build_tools.zip and b/diagram/build_tools.zip differ
diff --git a/diagram/operation_system_logo.zip b/diagram/operation_system_logo.zip
index fd91462..e335761 100644
Binary files a/diagram/operation_system_logo.zip and b/diagram/operation_system_logo.zip differ
diff --git a/diagram/program_language_logo.zip b/diagram/program_language_logo.zip
index c7f67d8..a07ac92 100644
Binary files a/diagram/program_language_logo.zip and b/diagram/program_language_logo.zip differ
diff --git a/docker/build_cpp.sh b/docker/build_cpp.sh
deleted file mode 120000
index 24eca94..0000000
--- a/docker/build_cpp.sh
+++ /dev/null
@@ -1 +0,0 @@
-build_cpp_bazel.sh
\ No newline at end of file
diff --git a/docker/build_cpp_cmake.sh b/docker/build_cpp_cmake.sh
deleted file mode 100755
index def97e6..0000000
--- a/docker/build_cpp_cmake.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/bash
-cd "$(
- cd "$(dirname "$0")" >/dev/null 2>&1
- pwd -P
-)/" || exit
-# https://github.com/npclaudiu/grpc-cpp-docker.git
-
-set -e
-
-export GRPC_VERSION=v1.62.0
-export GRPC_SOURCE=$(PWD)/grpc
-export GLOG_SOURCE=$(PWD)/glog
-export GFLAGS_SOURCE=$(PWD)/gflags
-export CATCH2_SOURCE=$(PWD)/Catch2
-
-echo "~~~ get grpc c++ sourcecode ~~~"
-sh build_cpp_get_src.sh $GRPC_VERSION $GRPC_SOURCE $GLOG_SOURCE $GFLAGS_SOURCE $CATCH2_SOURCE
-
-cd ..
-rm -rf docker/hello-grpc-cpp
-cp -r hello-grpc-cpp docker/
-rm -rf docker/hello-grpc-cpp/build
-
-cd docker
-echo "~~~ build grpc c++ PWD:$(PWD) ~~~"
-export port=56383
-export http_proxy=127.0.0.1:$port
-export https_proxy=127.0.0.1:$port
-echo "http_proxy: $http_proxy, https_proxy: $https_proxy"
-echo "1 build builder"
-docker build \
- --progress=plain \
- -f grpc-cpp.dockerfile --target build -t feuyeux/grpc_cpp:1.0.0 .
-echo "2 build server"
-docker build -f grpc-cpp.dockerfile --target server -t feuyeux/grpc_server_cpp:1.0.0 .
-echo "3 build client"
-docker build -f grpc-cpp.dockerfile --target client -t feuyeux/grpc_client_cpp:1.0.0 .
-
-rm -rf hello-grpc-cpp
-echo "DONE"
-
-# docker run --rm -it --entrypoint=bash feuyeux/grpc_server_cpp:1.0.0
diff --git a/docker/build_cpp_get_src.sh b/docker/build_cpp_get_src.sh
deleted file mode 100644
index 7f910b1..0000000
--- a/docker/build_cpp_get_src.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/bash
-cd "$(
- cd "$(dirname "$0")" >/dev/null 2>&1
- pwd -P
-)/" || exit
-
-# get latest version
-# https://github.com/grpc/grpc/releases/latest
-export GRPC_VERSION=${1:-v1.62.0}
-export GRPC_SOURCE=${2:-/tmp/grpc}
-export GLOG_SOURCE=${3:-/tmp/glog}
-export GFLAGS_SOURCE=${4:-/tmp/gflags}
-export CATCH2_SOURCE=${5:-/tmp/Catch2}
-
-echo "GRPC_VERSION: $GRPC_VERSION, GRPC_SOURCE: $GRPC_SOURCE, GLOG_SOURCE: $GLOG_SOURCE, GFLAGS_SOURCE: $GFLAGS_SOURCE, CATCH2_SOURCE: $CATCH2_SOURCE"
-
-# get source code
-if [ -d "$GRPC_SOURCE" ]; then
- echo "grpc source code exists"
-else
- git clone -b $GRPC_VERSION https://gitee.com/feuyeux/grpc "${GRPC_SOURCE}"
- cd "${GRPC_SOURCE}"
- export port=56383
- export http_proxy=127.0.0.1:$port
- export https_proxy=127.0.0.1:$port
- # cmake only
- git submodule update --init
-fi
-
-if [ -d "$GLOG_SOURCE" ]; then
- echo "glog source code exists"
-else
- git clone https://gitee.com/feuyeux/glog "${GLOG_SOURCE}"
-fi
-
-if [ -d "$GFLAGS_SOURCE" ]; then
- echo "gflags source code exists"
-else
- git clone https://gitee.com/feuyeux/gflags "${GFLAGS_SOURCE}"
-fi
-
-if [ ! -d "$CATCH2_SOURCE" ]; then
- git clone https://gitee.com/feuyeux/Catch2 "${CATCH2_SOURCE}"
-fi
diff --git a/docker/build_cpp_bazel.sh b/docker/cpp_build.sh
similarity index 57%
rename from docker/build_cpp_bazel.sh
rename to docker/cpp_build.sh
index 7b26652..17955d7 100644
--- a/docker/build_cpp_bazel.sh
+++ b/docker/cpp_build.sh
@@ -6,24 +6,24 @@ cd "$(
# https://github.com/npclaudiu/grpc-cpp-docker.git
set -e
-
+docker images | grep debian
cd ..
-rm -rf docker/hello-grpc-cpp-bazel
-cd hello-grpc-cpp-bazel
+rm -rf docker/hello-grpc-cpp
+cd hello-grpc-cpp
bazel clean
cd ..
-cp -r hello-grpc-cpp-bazel docker/
+cp -r hello-grpc-cpp docker/
cd docker
echo "1 build builder"
# --progress=plain
-docker build -f grpc-cpp-bazel.dockerfile --target build -t feuyeux/grpc_cpp:1.0.0 .
+docker build -f cpp_grpc.dockerfile --target build -t feuyeux/grpc_cpp:1.0.0 .
# docker run --rm -it --entrypoint=bash feuyeux/grpc_cpp:1.0.0
echo "2 build server"
-docker build -f grpc-cpp-bazel.dockerfile --target server -t feuyeux/grpc_server_cpp:1.0.0 .
+docker build -f cpp_grpc.dockerfile --target server -t feuyeux/grpc_server_cpp:1.0.0 .
echo "3 build client"
-docker build -f grpc-cpp-bazel.dockerfile --target client -t feuyeux/grpc_client_cpp:1.0.0 .
+docker build -f cpp_grpc.dockerfile --target client -t feuyeux/grpc_client_cpp:1.0.0 .
docker run --rm -it --entrypoint=bash feuyeux/grpc_server_cpp:1.0.0
diff --git a/docker/grpc-cpp-bazel.dockerfile b/docker/cpp_grpc.dockerfile
similarity index 71%
rename from docker/grpc-cpp-bazel.dockerfile
rename to docker/cpp_grpc.dockerfile
index 182d6f7..bff0d19 100644
--- a/docker/grpc-cpp-bazel.dockerfile
+++ b/docker/cpp_grpc.dockerfile
@@ -22,14 +22,18 @@ RUN apt-get update && apt-get install -y \
&& apt-get clean
COPY bazel-7.0.2-installer-linux-x86_64.sh /source/bazel-installer.sh
-COPY hello-grpc-cpp-bazel /source/hello-grpc-cpp-bazel
+COPY hello-grpc-cpp /source/hello-grpc-cpp
WORKDIR /source
RUN chmod +x bazel-installer.sh && ./bazel-installer.sh && export PATH="$PATH:$/source/bin"
-RUN cd hello-grpc-cpp-bazel && bazel build //:hello_server //:hello_client
+WORKDIR /source/hello-grpc-cpp
+RUN bazel build --jobs=8 //protos:hello_cc_grpc
+RUN bazel build --jobs=8 //common:hello_utils
+RUN bazel build --jobs=8 //common:hello_conn
+RUN bazel build --jobs=8 //:hello_server //:hello_client
FROM debian:12-slim AS server
WORKDIR /opt/hello-grpc/
-COPY --from=build /source/hello-grpc-cpp-bazel/bazel-bin/hello_server .
+COPY --from=build /source/hello-grpc-cpp/bazel-bin/hello_server .
COPY tls/server_certs /var/hello_grpc/server_certs
COPY tls/client_certs /var/hello_grpc/client_certs
RUN /sbin/ldconfig -v
@@ -37,7 +41,7 @@ CMD ["./hello_server"]
FROM debian:12-slim AS client
WORKDIR /opt/hello-grpc/
-COPY --from=build /source/hello-grpc-cpp-bazel/bazel-bin/hello_client .
+COPY --from=build /source/hello-grpc-cpp/bazel-bin/hello_client .
COPY tls/client_certs /var/hello_grpc/client_certs
RUN /sbin/ldconfig -v
CMD ["./hello_client"]
\ No newline at end of file
diff --git a/hello-grpc-cpp-bazel/BUILD.bazel b/hello-grpc-cpp-bazel/BUILD.bazel
deleted file mode 100644
index 5ab099f..0000000
--- a/hello-grpc-cpp-bazel/BUILD.bazel
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-licenses(["none"])
-
-package(default_visibility = ["//visibility:public"])
-
-cc_library(
- name = "hello_utils",
- srcs = ["common/utils.cpp"],
- hdrs = ["common/utils.h"],
- deps = [
- "//protos:hello_cc_grpc",
- "@com_github_google_glog//:glog",
- "@com_google_absl//absl/strings",
- "@com_google_absl//absl/random",
- "@com_google_absl//absl/random:distributions",
- ],
-)
-
-cc_library(
- name = "hello_conn",
- srcs = ["common/connection.cpp"],
- hdrs = ["common/connection.h"],
- deps = [
- "//protos:hello_cc_grpc",
- ":hello_utils",
- "@com_github_google_glog//:glog",
- "@com_google_absl//absl/strings",
- "@com_google_absl//absl/random",
- ],
-)
-
-cc_binary(
- name = "hello_server",
- srcs = ["server/proto_server.cpp"],
- defines = ["BAZEL_BUILD"],
- deps = [
- ":hello_conn",
- ":hello_utils",
- "//protos:hello_cc_grpc",
- "@com_github_grpc_grpc//:grpc++",
- "@com_github_grpc_grpc//:grpc++_reflection",
- "@catch2",
- ],
-)
-
-cc_binary(
- name = "hello_client",
- srcs = ["client/proto_client.cpp"],
- defines = ["BAZEL_BUILD"],
- deps = [
- ":hello_conn",
- ":hello_utils",
- "//protos:hello_cc_grpc",
- "@com_github_grpc_grpc//:grpc++",
- "@com_github_grpc_grpc//:grpc++_reflection",
- "@catch2",
- ],
-)
\ No newline at end of file
diff --git a/hello-grpc-cpp-bazel/MODULE.bazel b/hello-grpc-cpp-bazel/MODULE.bazel
deleted file mode 100644
index f301a95..0000000
--- a/hello-grpc-cpp-bazel/MODULE.bazel
+++ /dev/null
@@ -1,22 +0,0 @@
-"""This is a Bazel module file."""
-
-# https://registry.bazel.build/modules/glog
-bazel_dep(name = "glog", version = "0.7.0", repo_name = "com_github_google_glog")
-
-# https://registry.bazel.build/modules/catch2
-bazel_dep(name = "catch2", version = "3.5.2")
-
-# https://registry.bazel.build/modules/gflags
-bazel_dep(name = "gflags", version = "2.2.2",repo_name="com_github_gflags_gflags")
-
-# https://registry.bazel.build/modules/abseil-cpp
-bazel_dep(name = "abseil-cpp", version = "20230802.1", repo_name = "com_google_absl")
-
-# https://registry.bazel.build/modules/grpc
-bazel_dep(name = "grpc", version = "1.56.3", repo_name = "com_github_grpc_grpc")
-
-# https://registry.bazel.build/modules/rules_go
-bazel_dep(name = "rules_go", version = "0.46.0", repo_name = "io_bazel_rules_go")
-
-# https://registry.bazel.build/modules/protobuf
-bazel_dep(name = "protobuf", version = "23.1", repo_name = "com_google_protobuf")
\ No newline at end of file
diff --git a/hello-grpc-cpp-bazel/README.md b/hello-grpc-cpp-bazel/README.md
deleted file mode 100644
index 106a2a1..0000000
--- a/hello-grpc-cpp-bazel/README.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# grpc c++ demo
-
-
-
-## 1 Setup
-
-```bash
-sh init.sh
-```
-
-windows
-
-
-
-BAZEL_VC
-C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC
-
-```powershell
-cd c:\cooding\grpc
-bazel build :all
-```
-
-## 2 Build
-
-### cmake config
-
-`CMakeLists.txt`
-
-> set `$GRPC_INSTALL_PATH` for `CMAKE_PREFIX_PATH`
-
-```cmake
-set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/Users/han/.local")
-```
-
-### cmake & make
-
-```bash
-sh build.sh
-```
-
-## 3 Run
-
-```bash
-./build/proto_server
-```
-
-```bash
-./build/proto_client
-```
-
-## 4 Test
-
-```bash
-./build/tests
-```
diff --git a/hello-grpc-cpp-bazel/WORKSPACE.bk b/hello-grpc-cpp-bazel/WORKSPACE.bk
deleted file mode 100644
index c949681..0000000
--- a/hello-grpc-cpp-bazel/WORKSPACE.bk
+++ /dev/null
@@ -1,17 +0,0 @@
-load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
-
-local_repository(
- name = "com_github_grpc_grpc",
- path = "D:\\coding\\grpc",
-)
-
-local_repository(
- name = "com_google_absl",
- path = "D:\\coding\\grpc\\third_party\\abseil-cpp",
-)
-
-git_repository(
- name = "com_github_gflags_gflags",
- remote = "https://github.com/gflags/gflags.git",
- tag = "v2.2.2"
-)
\ No newline at end of file
diff --git a/hello-grpc-cpp-bazel/build.sh b/hello-grpc-cpp-bazel/build.sh
deleted file mode 100755
index ed7cc7b..0000000
--- a/hello-grpc-cpp-bazel/build.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-cd "$(
- cd "$(dirname "$0")" >/dev/null 2>&1
- pwd -P
-)/" || exit
-
-# proxy_port
-# export http_proxy=127.0.0.1:$proxy_port
-# export https_proxy=127.0.0.1:$proxy_port
-http_proxy=${http_proxy:-""}
-https_proxy=${https_proxy:-""}
-echo "http_proxy: $http_proxy, https_proxy: $https_proxy"
-echo "CHECK BAZEL"
-bazel version
-sleep 5
-echo "CHECK GCC"
-gcc -v
-sleep 5
-ncpu=$(sysctl hw.ncpu)
-physicalcpu=$(sysctl hw.physicalcpu)
-logicalcpu=$(sysctl hw.logicalcpu)
-echo "hw.ncpu: $ncpu,hw.physicalcpu: $physicalcpu,hw.logicalcpu: $logicalcpu"
-job_number=$ncpu+2
-bazel build --compiler=gcc-13 --jobs="$job_number" --sandbox_debug //:hello_server //:hello_client
diff --git a/hello-grpc-cpp-bazel/common/utils.h b/hello-grpc-cpp-bazel/common/utils.h
deleted file mode 100644
index a935e66..0000000
--- a/hello-grpc-cpp-bazel/common/utils.h
+++ /dev/null
@@ -1,38 +0,0 @@
-using namespace std;
-
-#include "protos/landing.grpc.pb.h"
-
-using org::feuyeux::grpc::TalkRequest;
-
-#include
-
-namespace hello
-{
- class Utils
- {
- public:
- static string hello(int index);
-
- static string uuid();
-
- static string thanks(string key);
-
- static list buildLinkRequests();
-
- static void initLog(char *const *argv);
-
- static int random(int n);
-
- static long now();
-
- static string getServerHost();
-
- static string getServerPort();
-
- static string getBackend();
-
- static string getBackendPort();
-
- static string getSecure();
- };
-}
diff --git a/hello-grpc-cpp-cmake/CMakeLists.txt b/hello-grpc-cpp-cmake/CMakeLists.txt
deleted file mode 100644
index 9c2ea6b..0000000
--- a/hello-grpc-cpp-cmake/CMakeLists.txt
+++ /dev/null
@@ -1,69 +0,0 @@
-cmake_minimum_required(VERSION 3.18)
-project(Hello-GRPC-CPP C CXX)
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "$ENV{HOME}/.local")
-include(cmake/common.cmake)
-
-# Proto file
-get_filename_component(landing_proto "protos/landing.proto" ABSOLUTE)
-get_filename_component(landing_proto_path "${landing_proto}" PATH)
-
-# Generated sources
-set(PB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/common")
-
-set(landing_proto_srcs "${PB_PATH}/landing.pb.cc")
-set(landing_proto_hdrs "${PB_PATH}/landing.pb.h")
-set(landing_grpc_srcs "${PB_PATH}/landing.grpc.pb.cc")
-set(landing_grpc_hdrs "${PB_PATH}/landing.grpc.pb.h")
-set(landing_grpc_utils_head "${CMAKE_CURRENT_SOURCE_DIR}/common/utils.h")
-set(landing_grpc_utils_src "${CMAKE_CURRENT_SOURCE_DIR}/common/utils.cpp" common/connection.cpp common/connection.h)
-
-add_custom_command(
- OUTPUT "${landing_proto_srcs}" "${landing_proto_hdrs}" "${landing_grpc_srcs}" "${landing_grpc_hdrs}"
- COMMAND ${_PROTOBUF_PROTOC}
- ARGS --grpc_out "${PB_PATH}"
- --cpp_out "${PB_PATH}"
- -I "${landing_proto_path}"
- --plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
- "${landing_proto}"
- DEPENDS "${landing_proto}")
-
-# Include generated *.pb.h files
-include_directories("${PB_PATH}")
-
-#https://cmake.org/cmake/help/latest/command/add_library.html
-#add_library( [STATIC | SHARED | MODULE]
-# [EXCLUDE_FROM_ALL]
-# [...])
-add_library(landing_grpc_proto
- ${landing_grpc_srcs} ${landing_grpc_hdrs}
- ${landing_proto_srcs} ${landing_proto_hdrs}
- ${landing_grpc_utils_src} ${landing_grpc_utils_head})
-target_link_libraries(landing_grpc_proto ${_REFLECTION} ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF})
-
-# Targets [async_](client|server)
-#https://cmake.org/cmake/help/latest/command/add_executable.html
-add_executable(proto_client "client/proto_client.cpp")
-add_executable(proto_server "server/proto_server.cpp")
-add_executable(tests "tests/hello_test.cpp")
-
-# dependencies
-# LOG
-find_package(glog 0.7.0 REQUIRED)
-# UT
-find_package(Catch2 3 REQUIRED)
-# UUID
-#find_package(uuid_v4 1.0.0 REQUIRED)
-
-#https://cmake.org/cmake/help/latest/command/target_link_libraries.html
-target_link_libraries(proto_server landing_grpc_proto ${_REFLECTION} ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF} glog::glog #[[uuid_v4::uuid_v4]])
-target_link_libraries(proto_client landing_grpc_proto ${_REFLECTION} ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF} glog::glog)
-target_link_libraries(tests PRIVATE Catch2::Catch2 landing_grpc_proto glog::glog)
-
-include(CTest)
-include(Catch)
-catch_discover_tests(tests)
-
-#https://cmake.org/cmake/help/latest/command/add_definitions.html
-#add_definitions(-DFOO -DBAR ...)
-add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
diff --git a/hello-grpc-cpp-cmake/CXX_STANDARD_14.txt b/hello-grpc-cpp-cmake/CXX_STANDARD_14.txt
deleted file mode 100644
index 69f4235..0000000
--- a/hello-grpc-cpp-cmake/CXX_STANDARD_14.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-## Add c++14 flags BEGIN ##
-if (NOT DEFINED CMAKE_CXX_STANDARD)
- set(CMAKE_CXX_STANDARD 14)
-else()
- if (CMAKE_CXX_STANDARD LESS 14)
- message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 14, please specify at least SET(CMAKE_CXX_STANDARD 14)")
- endif()
-endif()
-if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
-endif()
-if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
- set(CMAKE_CXX_EXTENSIONS OFF)
-endif()
-
-## Add c++14 flags END ##
diff --git a/hello-grpc-cpp-cmake/FEATURE.md b/hello-grpc-cpp-cmake/FEATURE.md
deleted file mode 100644
index d78a094..0000000
--- a/hello-grpc-cpp-cmake/FEATURE.md
+++ /dev/null
@@ -1,16 +0,0 @@
-# Features
-
-- [X] 4 GRPC MODELS
- - [X] Env
- - [X] Array
- - [X] random
- - [X] Timestamp
- - [] UUID
- - [X] Sleep
-- [X] LOG
-- [X] SEND/RECEIVE HEADERS
-- [X] DOCKER IMAGE
-- [X] CROSS ACCESS
-- [X] AS PRO Y(FRONT-BACK)
-- [X] PROPAGATE TRACING HEADERS
-- [X] TLS
diff --git a/hello-grpc-cpp-cmake/README.md b/hello-grpc-cpp-cmake/README.md
deleted file mode 100644
index 106a2a1..0000000
--- a/hello-grpc-cpp-cmake/README.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# grpc c++ demo
-
-
-
-## 1 Setup
-
-```bash
-sh init.sh
-```
-
-windows
-
-
-
-BAZEL_VC
-C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC
-
-```powershell
-cd c:\cooding\grpc
-bazel build :all
-```
-
-## 2 Build
-
-### cmake config
-
-`CMakeLists.txt`
-
-> set `$GRPC_INSTALL_PATH` for `CMAKE_PREFIX_PATH`
-
-```cmake
-set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/Users/han/.local")
-```
-
-### cmake & make
-
-```bash
-sh build.sh
-```
-
-## 3 Run
-
-```bash
-./build/proto_server
-```
-
-```bash
-./build/proto_client
-```
-
-## 4 Test
-
-```bash
-./build/tests
-```
diff --git a/hello-grpc-cpp-cmake/build.sh b/hello-grpc-cpp-cmake/build.sh
deleted file mode 100755
index dbbe8b4..0000000
--- a/hello-grpc-cpp-cmake/build.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-cd "$(
- cd "$(dirname "$0")" >/dev/null 2>&1
- pwd -P
-)/" || exit
-set -e
-
-echo "cmake:"
-if [ ! -d "build" ]; then
- mkdir build
-else
- rm -rf build
- mkdir build
-fi
-
-echo "start to build hello grpc ..."
-pushd build
-cmake -DCMAKE_BUILD_TYPE=Release ..
-echo
-
-echo "make:"
-make -j 4
-popd
-echo "build hello grpc successfully."
diff --git a/hello-grpc-cpp-cmake/build_official_sample.sh b/hello-grpc-cpp-cmake/build_official_sample.sh
deleted file mode 100644
index 8bac19b..0000000
--- a/hello-grpc-cpp-cmake/build_official_sample.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash
-set -e
-
-# https://grpc.io/docs/languages/cpp/quickstart/#Build%20The%20Example
-echo " == try to build the hello world == "
-cd "$GRPC_SRC_HOME/examples/cpp/helloworld"
-export MY_INSTALL_DIR=$HOME/.local
-mkdir -p $MY_INSTALL_DIR
-export PATH="$MY_INSTALL_DIR/bin:$PATH"
-mkdir -p cmake/build
-pushd cmake/build
-cmake -DCMAKE_PREFIX_PATH=$MY_INSTALL_DIR ../..
-make -j 4
\ No newline at end of file
diff --git a/hello-grpc-cpp-cmake/client/proto_client.cpp b/hello-grpc-cpp-cmake/client/proto_client.cpp
deleted file mode 100644
index 32a7f39..0000000
--- a/hello-grpc-cpp-cmake/client/proto_client.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-#include
-#include
-#include
-
-#include
-#include "landing.grpc.pb.h"
-#include
-#include
-#include "connection.h"
-#include "utils.h"
-
-using grpc::Channel;
-using grpc::ClientContext;
-using grpc::Status;
-using org::feuyeux::grpc::TalkRequest;
-using org::feuyeux::grpc::TalkResponse;
-using org::feuyeux::grpc::LandingService;
-using org::feuyeux::grpc::TalkResult;
-using org::feuyeux::grpc::ResultType;
-using grpc::ClientReader;
-using grpc::ClientWriter;
-using grpc::ClientReaderWriter;
-using google::protobuf::RepeatedPtrField;
-using google::protobuf::Map;
-using std::string;
-using hello::Connection;
-using hello::Utils;
-
-class LandingClient {
-public:
- explicit LandingClient(const std::shared_ptr &channel) : client(LandingService::NewStub(channel)) {}
-
- void Talk() {
- ClientContext context;
- buildHeaders(context);
- TalkResponse talkResponse;
- TalkRequest talkRequest;
- talkRequest.set_data("1");
- talkRequest.set_meta("C++");
- Status status = client->Talk(&context, talkRequest, &talkResponse);
- if (status.ok()) {
- printResponse(context, talkResponse);
- } else {
- LOG(INFO) << "Error:" << status.error_code() << ": " << status.error_message();
- }
- }
-
- void TalkOneAnswerMore() {
- ClientContext context;
- buildHeaders(context);
- TalkResponse talkResponse;
- TalkRequest talkRequest;
- talkRequest.set_data("1,2,3");
- talkRequest.set_meta("C++");
- const std::unique_ptr<::grpc::ClientReader>
- &response(client->TalkOneAnswerMore(&context, talkRequest));
- while (response->Read(&talkResponse)) {
- printResponse(context, talkResponse);
- }
- }
-
- void TalkMoreAnswerOne() {
- ClientContext context;
- buildHeaders(context);
- TalkResponse talkResponse;
- std::unique_ptr> writer(client->TalkMoreAnswerOne(&context, &talkResponse));
- const list &requests = Utils::buildLinkRequests();
- for (auto &&request: requests) {
- if (!writer->Write(request)) {
- // Broken stream.
- break;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
- }
- writer->WritesDone();
- Status status = writer->Finish();
- if (status.ok()) {
- printResponse(context, talkResponse);
- } else {
- LOG(INFO) << "Error:" << status.error_code() << ": " << status.error_message();
- }
- }
-
- void TalkBidirectional() {
- ClientContext context;
- buildHeaders(context);
- TalkResponse talkResponse;
- std::shared_ptr> stream(client->TalkBidirectional(&context));
- std::thread writer([stream]() {
- const list &requests = Utils::buildLinkRequests();
- for (auto &&request: requests) {
- stream->Write(request);
- }
- stream->WritesDone();
- });
- while (stream->Read(&talkResponse)) {
- printResponse(context, talkResponse);
- }
- writer.join();
- Status status = stream->Finish();
- if (!status.ok()) {
- LOG(INFO) << "Error:" << status.error_code() << ": " << status.error_message();
- }
- }
-
- static void printResponse(ClientContext &context, const TalkResponse &response) {
- const multimap &headers = context.GetServerInitialMetadata();
- for (const auto &header: headers) {
- LOG(INFO) << "<-H " << header.first << ":" << header.second;
- }
- const RepeatedPtrField &talkResults = response.results();
- for (const TalkResult &result: talkResults) {
- const Map &kv = result.kv();
- string id(kv.at("id"));
- string idx(kv.at("idx"));
- string meta(kv.at("meta"));
- string data(kv.at("data"));
- LOG(INFO) << response.status()
- << " " << result.id()
- << " [" << meta
- << " " << ResultType_Name(result.type())
- << " " << id
- << " " << idx
- << " " << data
- << "]";
- }
- const multimap &tails = context.GetServerTrailingMetadata();
- for (const auto &tail: tails) {
- LOG(INFO) << "<-L " << tail.first << ":" << tail.second;
- }
- }
-
- static void buildHeaders(ClientContext &context) {
- //examples/cpp/metadata
- context.AddMetadata("k1", "v1");
- context.AddMetadata("k2", "v2");
- }
-
-private:
- std::unique_ptr client;
-};
-
-int main(__attribute__((unused)) int argc, char **argv) {
- Utils::initLog(argv);
- LandingClient landingClient(Connection::getChannel());
- LOG(INFO) << "Unary RPC";
- landingClient.Talk();
- LOG(INFO) << "Server streaming RPC";
- landingClient.TalkOneAnswerMore();
- LOG(INFO) << "Client streaming RPC";
- landingClient.TalkMoreAnswerOne();
- LOG(INFO) << "Bidirectional streaming RPC";
- landingClient.TalkBidirectional();
- google::ShutdownGoogleLogging();
- return 0;
-}
\ No newline at end of file
diff --git a/hello-grpc-cpp-cmake/client_start.sh b/hello-grpc-cpp-cmake/client_start.sh
deleted file mode 100755
index 60b8561..0000000
--- a/hello-grpc-cpp-cmake/client_start.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-cd "$(
- cd "$(dirname "$0")" >/dev/null 2>&1
- pwd -P
-)/" || exit
-
-./build/proto_client --target=localhost:9996
\ No newline at end of file
diff --git a/hello-grpc-cpp-cmake/cmake/common.cmake b/hello-grpc-cpp-cmake/cmake/common.cmake
deleted file mode 100644
index 749469b..0000000
--- a/hello-grpc-cpp-cmake/cmake/common.cmake
+++ /dev/null
@@ -1,104 +0,0 @@
-cmake_minimum_required(VERSION 3.18)
-
-set(CMAKE_CXX_STANDARD 11)
-
-if (MSVC)
- add_definitions(-D_WIN32_WINNT=0x600)
-endif ()
-
-find_package(Threads REQUIRED)
-
-if (GRPC_AS_SUBMODULE)
- # One way to build a projects that uses gRPC is to just include the
- # entire gRPC project tree via "add_subdirectory".
- # This approach is very simple to use, but the are some potential
- # disadvantages:
- # * it includes gRPC's CMakeLists.txt directly into your build script
- # without and that can make gRPC's internal setting interfere with your
- # own build.
- # * depending on what's installed on your system, the contents of submodules
- # in gRPC's third_party/* might need to be available (and there might be
- # additional prerequisites required to build them). Consider using
- # the gRPC_*_PROVIDER options to fine-tune the expected behavior.
- #
- # A more robust approach to add dependency on gRPC is using
- # cmake's ExternalProject_Add (see cmake_externalproject/CMakeLists.txt).
-
- # Include the gRPC's cmake build (normally grpc source code would live
- # in a git submodule called "third_party/grpc", but this example lives in
- # the same repository as gRPC sources, so we just look a few directories up)
- add_subdirectory(../../.. ${CMAKE_CURRENT_BINARY_DIR}/grpc EXCLUDE_FROM_ALL)
- message(STATUS "Using gRPC via add_subdirectory.")
-
- # After using add_subdirectory, we can now use the grpc targets directly from
- # this build.
- set(_PROTOBUF_LIBPROTOBUF libprotobuf)
- set(_REFLECTION grpc++_reflection)
- if (CMAKE_CROSSCOMPILING)
- find_program(_PROTOBUF_PROTOC protoc)
- else ()
- set(_PROTOBUF_PROTOC $)
- endif ()
- set(_GRPC_GRPCPP grpc++)
- if (CMAKE_CROSSCOMPILING)
- find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
- else ()
- set(_GRPC_CPP_PLUGIN_EXECUTABLE $)
- endif ()
-elseif (GRPC_FETCHCONTENT)
- # Another way is to use CMake's FetchContent module to clone gRPC at
- # configure time. This makes gRPC's source code available to your project,
- # similar to a git submodule.
- message(STATUS "Using gRPC via add_subdirectory (FetchContent).")
- include(FetchContent)
- FetchContent_Declare(
- grpc
- GIT_REPOSITORY https://github.com/grpc/grpc.git
- # when using gRPC, you will actually set this to an existing tag, such as
- # v1.25.0, v1.26.0 etc..
- # For the purpose of testing, we override the tag used to the commit
- # that's currently under test.
- GIT_TAG vGRPC_TAG_VERSION_OF_YOUR_CHOICE)
- FetchContent_MakeAvailable(grpc)
-
- # Since FetchContent uses add_subdirectory under the hood, we can use
- # the grpc targets directly from this build.
- set(_PROTOBUF_LIBPROTOBUF libprotobuf)
- set(_REFLECTION grpc++_reflection)
- set(_PROTOBUF_PROTOC $)
- set(_GRPC_GRPCPP grpc++)
- if (CMAKE_CROSSCOMPILING)
- find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
- else ()
- set(_GRPC_CPP_PLUGIN_EXECUTABLE $)
- endif ()
-else ()
- # This branch assumes that gRPC and all its dependencies are already installed
- # on this system, so they can be located by find_package().
-
- # Find Protobuf installation
- # Looks for protobuf-config.cmake file installed by Protobuf's cmake installation.
- set(protobuf_MODULE_COMPATIBLE TRUE)
- find_package(Protobuf CONFIG REQUIRED)
- message(STATUS "Using protobuf ${Protobuf_VERSION}")
-
- set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
- set(_REFLECTION gRPC::grpc++_reflection)
- if (CMAKE_CROSSCOMPILING)
- find_program(_PROTOBUF_PROTOC protoc)
- else ()
- set(_PROTOBUF_PROTOC $)
- endif ()
-
- # Find gRPC installation
- # Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
- find_package(gRPC CONFIG REQUIRED)
- message(STATUS "Using gRPC ${gRPC_VERSION}")
-
- set(_GRPC_GRPCPP gRPC::grpc++)
- if (CMAKE_CROSSCOMPILING)
- find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
- else ()
- set(_GRPC_CPP_PLUGIN_EXECUTABLE $)
- endif ()
-endif ()
diff --git a/hello-grpc-cpp-cmake/common/connection.cpp b/hello-grpc-cpp-cmake/common/connection.cpp
deleted file mode 100644
index 4e7b26d..0000000
--- a/hello-grpc-cpp-cmake/common/connection.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include
-#include
-#include
-#include
-#include "connection.h"
-#include "utils.h"
-
-using grpc::Channel;
-
-namespace hello {
- string Connection::getFileContent(const char *path) {
- std::ifstream stream(path);
- std::string contents;
- contents.assign((std::istreambuf_iterator(stream)), std::istreambuf_iterator());
- stream.close();
- return contents;
- }
-
- shared_ptr Connection::getChannel() {
- //https://myssl.com/create_test_cert.html
- const char cert[] = "/var/hello_grpc/client_certs/cert.pem";
- const char certKey[] = "/var/hello_grpc/client_certs/private.key";
- const char certChain[] = "/var/hello_grpc/client_certs/full_chain.pem";
- const char rootCert[] = "/var/hello_grpc/client_certs/myssl_root.cer";
- const string serverName = "hello.grpc.io";
-
- const string &port = Utils::getBackendPort();
- const basic_string, allocator> &target = Utils::getBackend() + ":" + port;
- const string &secure = Utils::getSecure();
- if (!secure.empty() && secure == "Y") {
- grpc::SslCredentialsOptions ssl_opts;
- ssl_opts.pem_root_certs = Connection::getFileContent(certChain);
- ssl_opts.pem_private_key = Connection::getFileContent(certKey);
- ssl_opts.pem_cert_chain = Connection::getFileContent(certChain);
- grpc::ChannelArguments channel_args;
- channel_args.SetString("grpc.default_authority", serverName);
- LOG(INFO) << "Connect with TLS(" << port << ")";
- return grpc::CreateCustomChannel(target, grpc::SslCredentials(ssl_opts), channel_args);
- } else {
- LOG(INFO) << "Connect with InSecure(" << port << ")";
- return grpc::CreateChannel(target, grpc::InsecureChannelCredentials());
- }
- }
-}
diff --git a/hello-grpc-cpp-cmake/common/connection.h b/hello-grpc-cpp-cmake/common/connection.h
deleted file mode 100644
index ae8308f..0000000
--- a/hello-grpc-cpp-cmake/common/connection.h
+++ /dev/null
@@ -1,11 +0,0 @@
-using namespace std;
-using grpc::Channel;
-
-namespace hello {
- class Connection {
- public:
- static string getFileContent(const char *path);
-
- static shared_ptr getChannel();
- };
-}
diff --git a/hello-grpc-cpp-cmake/common/utils.cpp b/hello-grpc-cpp-cmake/common/utils.cpp
deleted file mode 100644
index 3f31843..0000000
--- a/hello-grpc-cpp-cmake/common/utils.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-#include
-#include
-#include
-#include "utils.h"
-#include