parent
72b2ef8340
commit
333b1299c2
|
@ -95,7 +95,7 @@ jobs:
|
|||
mode: [ Release, Debug ]
|
||||
libcxx: [ OFF ]
|
||||
io_uring: [ ON ]
|
||||
case_name: [ test_corofile ]
|
||||
case_name: [ coro_io_test ]
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ jobs:
|
|||
matrix:
|
||||
mode: [Release, Debug]
|
||||
io_uring: [ ON ]
|
||||
case_name: [ test_corofile ]
|
||||
case_name: [ coro_io_test ]
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
|
|
88
BUILD.bazel
88
BUILD.bazel
|
@ -2,90 +2,12 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
cc_library(
|
||||
name = "struct_pack",
|
||||
name = "ylt",
|
||||
hdrs = glob([
|
||||
"include/util/expected.hpp",
|
||||
"include/struct_pack/struct_pack/*.hpp",
|
||||
"include/struct_pack/struct_pack/*.h",
|
||||
]) + ["include/struct_pack/struct_pack.hpp"],
|
||||
include_prefix = "include",
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "struct_pb",
|
||||
hdrs = glob([
|
||||
"include/struct_pb/struct_pb/*.hpp",
|
||||
]) + ["include/struct_pb/struct_pb.hpp"],
|
||||
include_prefix = "include",
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "struct_json",
|
||||
hdrs = glob([
|
||||
"include/struct_json/*.h",
|
||||
"include/**",
|
||||
"src/include/**"
|
||||
]),
|
||||
include_prefix = "include",
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//thirdparty:frozen",
|
||||
"//thirdparty:iguana",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "easylog",
|
||||
hdrs = glob([
|
||||
"include/easylog/*.hpp",
|
||||
"include/easylog/*.h",
|
||||
]) + [
|
||||
"include/util/dragonbox.h",
|
||||
"include/util/dragonbox_to_chars.h",
|
||||
"include/util/meta_string.hpp",
|
||||
"include/util/type_traits.h",
|
||||
],
|
||||
include_prefix = "include",
|
||||
includes = ["include"],
|
||||
includes = ["include", "include/ylt/thirdparty","src/include"],
|
||||
linkopts = ["-lpthread"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "coro_rpc",
|
||||
hdrs = glob([
|
||||
"include/coro_rpc/**/*.hpp",
|
||||
"include/coro_io/*.hpp",
|
||||
"include/util/*.hpp",
|
||||
"include/util/*.h",
|
||||
]),
|
||||
include_prefix = "include",
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//:easylog",
|
||||
"//:struct_pack",
|
||||
"//thirdparty:asio",
|
||||
"//thirdparty:async_simple",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "coro_http",
|
||||
hdrs = glob([
|
||||
"include/coro_http/*.h",
|
||||
"include/coro_io/*.hpp",
|
||||
"include/util/*.h",
|
||||
"include/util/*.hpp",
|
||||
]),
|
||||
include_prefix = "include",
|
||||
includes = ["include"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//thirdparty:asio",
|
||||
"//thirdparty:async_simple",
|
||||
"//thirdparty:cinatra",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -1,21 +1,27 @@
|
|||
cmake_minimum_required(VERSION 3.15)
|
||||
project(yaLanTingLibs
|
||||
VERSION 1.0.0
|
||||
VERSION 0.2.0
|
||||
DESCRIPTION "yaLanTingLibs"
|
||||
HOMEPAGE_URL "https://github.com/alibaba/yalantinglibs"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
# add include path
|
||||
include_directories(include)
|
||||
include_directories(include/ylt/thirdparty)
|
||||
include_directories(src/include)
|
||||
|
||||
#the thread library of the system.
|
||||
find_package(Threads REQUIRED)
|
||||
link_libraries(Threads::Threads)
|
||||
|
||||
include(cmake/utils.cmake)
|
||||
include(cmake/struct_pb.cmake)
|
||||
include(cmake/build.cmake)
|
||||
include(cmake/platform.cmake)
|
||||
include(cmake/dependency.cmake)
|
||||
include(cmake/develop.cmake)
|
||||
include(cmake/install.cmake)
|
||||
include(cmake/module.cmake)
|
||||
# add project config, such as enable_ssl.
|
||||
include(cmake/config.cmake)
|
||||
# add project's source such as unit test, example & benchmark
|
||||
include(cmake/subdirectory.cmake)
|
||||
|
||||
|
||||
|
|
4
NOTICE
4
NOTICE
|
@ -9,7 +9,7 @@ This section summarizes those components and their licenses.
|
|||
Apache Software Foundation License 2.0
|
||||
--------------------------------------
|
||||
|
||||
struct_pack/struct_pack/md5_constexpr.hpp
|
||||
ylt/struct_pack/texpr.hpp
|
||||
|
||||
BSD 3-Clause "New" or "Revised" License
|
||||
--------------------------------------
|
||||
|
@ -22,7 +22,7 @@ Creative Commons Zero v1.0 Universal License
|
|||
|
||||
test/doctest.h
|
||||
|
||||
include/struct_pack/struct_pack/tuplet.hpp
|
||||
include/ylt/struct_pack/pp
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at <http://www.boost.org/LICENSE_1_0.txt>)
|
||||
|
|
232
README.md
232
README.md
|
@ -21,6 +21,78 @@ The target of yaLanTingLibs: provide very easy and high performance C++20 librar
|
|||
| macOS Monterey 12 (AppleClang 14.0.0.14000029) |  |
|
||||
| Windows Server 2022 (MSVC 19.33.31630.0) |  |
|
||||
|
||||
|
||||
# Quick Start
|
||||
## compiler requirements
|
||||
|
||||
make sure you have such compilers:
|
||||
- clang11 and libstdc++-8 above;
|
||||
- or gcc10 and g++10 above;
|
||||
- msvc 14.29 above;
|
||||
|
||||
## Install & Compile
|
||||
|
||||
Yalantinglibs is a head-only library. You can just copy `./include/ylt` directory into your project. But we suggest you use cmake to install it.
|
||||
|
||||
1. clone repo
|
||||
|
||||
```shell
|
||||
git clone https://github.com/alibaba/yalantinglibs.git
|
||||
cd yalantinglibs
|
||||
mkdir build
|
||||
cd build
|
||||
```
|
||||
|
||||
2. build & test
|
||||
|
||||
- We suggest you compile the example and test the code first:
|
||||
|
||||
```shell
|
||||
cmake ..
|
||||
cmake --build . --config debug # add -j, if you have enough memory to parallel compile
|
||||
ctest . # run tests
|
||||
```
|
||||
|
||||
You can see the test/example/benchmark executable file in `./build/output/`.
|
||||
|
||||
- Or you can just skip build example/test/benchmark:
|
||||
|
||||
```shell
|
||||
# You can use those option to skip build unit-test & benchmark & example:
|
||||
cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARK=OFF -DBUILD_UNIT_TESTS=OFF
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
3. install
|
||||
|
||||
```shell
|
||||
cmake --install . # --prefix ./user_defined_install_path
|
||||
```
|
||||
|
||||
4. start develop
|
||||
|
||||
- Use Cmake:
|
||||
|
||||
After install ylt, copy then open the directory `src/*/examples`, then:
|
||||
|
||||
```shell
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
- Compile Manually:
|
||||
|
||||
1. Add `include/`'s parent to include path(skip it if you have install ylt into system default path)
|
||||
2. Add `include/ylt/thirdparty` to include path(skip it if you have install thirdparty independency by the cmake option -DINSTALL_INDEPENDENT_THIRDPARTY=ON)
|
||||
3. If you use any header with `coro_` prefix, add link option `-pthread` in linux and add option `-fcoroutines` when you use `g++`
|
||||
4. That's all. You can alos find other options in `example/cmakelist.txt`.
|
||||
|
||||
- More Details:
|
||||
For more details, except `example/cmakelist.txt`, You can also see the cmake file [here](https://github.com/alibaba/yalantinglibs/tree/main/CmakeLists.txt) and [there](https://github.com/alibaba/yalantinglibs/tree/main/cmake).
|
||||
|
||||
# Introduction
|
||||
## coro_rpc
|
||||
|
||||
Very easy-to-use, coroutine-based, high performance rpc framework with C++20, more than 0.4M QPS per thread in pipeline mode. coro_rpc is a header only library.
|
||||
|
@ -48,7 +120,7 @@ inline std::string_view echo(std::string_view str) { return str; }
|
|||
|
||||
```cpp
|
||||
#include "rpc_service.hpp"
|
||||
#include <coro_rpc/coro_rpc_server.hpp>
|
||||
#include <ylt/coro_rpc/coro_rpc_server.hpp>
|
||||
|
||||
int main() {
|
||||
coro_rpc_server server(/*thread_num =*/10, /*port =*/9000);
|
||||
|
@ -61,7 +133,7 @@ int main() {
|
|||
|
||||
```cpp
|
||||
#include "rpc_service.hpp"
|
||||
#include <coro_rpc/coro_rpc_client.hpp>
|
||||
#include <ylt/coro_rpc/coro_rpc_client.hpp>
|
||||
|
||||
Lazy<void> test_client() {
|
||||
coro_rpc_client client;
|
||||
|
@ -120,8 +192,8 @@ reflection-based json lib, very easy to do struct to json and json to struct.
|
|||
|
||||
### quick example
|
||||
```cpp
|
||||
#include "struct_json/json_reader.h"
|
||||
#include "struct_json/json_writer.h"
|
||||
#include "ylt/struct_json/json_reader.h"
|
||||
#include "ylt/struct_json/json_writer.h"
|
||||
|
||||
struct person {
|
||||
std::string name;
|
||||
|
@ -144,8 +216,8 @@ reflection-based xml lib, very easy to do struct to xml and xml to struct.
|
|||
|
||||
### quick example
|
||||
```cpp
|
||||
#include "struct_xml/xml_reader.h"
|
||||
#include "struct_xml/xml_writer.h"
|
||||
#include "ylt/struct_xml/xml_reader.h"
|
||||
#include "ylt/struct_xml/xml_writer.h"
|
||||
|
||||
struct person {
|
||||
std::string name;
|
||||
|
@ -178,8 +250,8 @@ reflection-based yaml lib, very easy to do struct to yaml and yaml to struct.
|
|||
|
||||
### quick example
|
||||
```cpp
|
||||
#include "struct_yaml/yaml_reader.h"
|
||||
#include "struct_yaml/yaml_writer.h"
|
||||
#include "ylt/struct_yaml/yaml_reader.h"
|
||||
#include "ylt/struct_yaml/yaml_writer.h"
|
||||
|
||||
struct person {
|
||||
std::string name;
|
||||
|
@ -210,7 +282,7 @@ coro_http is a C++20 coroutine http(https) client, include: get/post, websocket,
|
|||
|
||||
### get/post
|
||||
```c++
|
||||
#include "coro_http/coro_http_client.h"
|
||||
#include "ylt/coro_http/coro_http_client.hpp"
|
||||
using namespace coro_http;
|
||||
|
||||
async_simple::coro::Lazy<void> get_post(coro_http_client &client) {
|
||||
|
@ -283,88 +355,74 @@ async_simple::coro::Lazy<void> download_files(coro_http_client &client) {
|
|||
A C++ 20 coroutine library offering simple, light-weight and easy-to-use components to write asynchronous codes.
|
||||
See [async_simple](https://github.com/alibaba/async_simple)
|
||||
|
||||
## compiler requirements
|
||||
# Details
|
||||
|
||||
make sure you have such compilers:
|
||||
- clang11 and libstdc++-8 above;
|
||||
- or gcc10 and g++10 above;
|
||||
- msvc 14.29 或更高版本。
|
||||
## CMAKE OPTION
|
||||
|
||||
## Quick Start
|
||||
These CMake options is used for yalantinglibs developing/installing itself. They are not effected for your project, because ylt is a head-only.
|
||||
|
||||
- clone repo
|
||||
### INSTALL OPTION
|
||||
|
||||
```shell
|
||||
git clone https://github.com/alibaba/yalantinglibs.git
|
||||
```
|
||||
|option|default value|
|
||||
|----------|------------|
|
||||
|INSTALL_THIRDPARTY|ON|
|
||||
|INSTALL_INDEPENDENT_THIRDPARTY|OFF|
|
||||
|
||||
- build, test & install (linux/macos)
|
||||
### ylt develop option
|
||||
|
||||
```shell
|
||||
cd yalantinglibs
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
# You can use those option to skip build unit-test & benchmark & example:
|
||||
# cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARK=OFF -DBUILD_UNIT_TESTS=OFF
|
||||
make # if your machine has enough memory, use `make -j` to speed up
|
||||
ctest . # run tests
|
||||
make install
|
||||
```
|
||||
|option|default value|
|
||||
|----------|------------|
|
||||
|BUILD_EXAMPLES|ON|
|
||||
|BUILD_BENCHMARK|ON|
|
||||
|BUILD_UNIT_TESTS|ON|
|
||||
|COVERAGE_TEST|OFF|
|
||||
|GENERATE_BENCHMARK_DATA|OFF|
|
||||
|CORO_RPC_USE_OTHER_RPC|ON|
|
||||
|
||||
- build & test( windows)
|
||||
### ylt config option
|
||||
|
||||
You can use the IDE which support CMake to build & test the source, such as Visual Studio/Clion/Visual Studio Code.
|
||||
These option maybe useful for your project. If you want to enable it in your project, see the cmake code [here](https://github.com/alibaba/yalantinglibs/tree/main/cmake/config.cmake)
|
||||
|
||||
- start your coding
|
||||
|option|default value|
|
||||
|----------|------------|
|
||||
|ENABLE_SSL|OFF|
|
||||
|ENABLE_PMR|OFF|
|
||||
|ENABLE_IO_URING|OFF|
|
||||
|ENABLE_FILE_IO_URING|OFF|
|
||||
|ENABLE_STRUCT_PACK_UNPORTABLE_TYPE|OFF|
|
||||
|ENABLE_STRUCT_PACK_OPTIMIZE|OFF|
|
||||
|
||||
Here is the sample code, you can start your project on this.
|
||||
## Thirdparty Dependency
|
||||
|
||||
In default, yalantinglibs will install thirdparty librarys in `ylt/thirdparty`. You need add it to include path when compile.
|
||||
|
||||
If you don't want to install the thirdparty librarys, you can turn off cmake option `-DINSTALL_THIRDPARTY=OFF`.
|
||||
If you want to install the thirdparty independence(direct install it in system include path so that you don't need add `ylt/thirdparty` to include path), you can use turn on cmake option `-DINSTALL_INDEPENDENT_THIRDPARTY=ON`.
|
||||
|
||||
Here are the thirdparty libraries we used(Although async_simple is a part of ylt, it open source first, so we import it as a independence thirdparty library).
|
||||
|
||||
### coro_io
|
||||
|
||||
- [asio](https://think-async.com/Asio)
|
||||
- [async_simple](https://github.com/alibaba/async_simple)
|
||||
- [openssl](https://www.openssl.org/) (optional)
|
||||
|
||||
### coro_rpc
|
||||
|
||||
```shell
|
||||
cd yalantinglibs/src/coro_rpc/examples/helloworld
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
make
|
||||
# For more detail, see Cmakelist.txt in helloworld.
|
||||
```
|
||||
- [asio](https://think-async.com/Asio)
|
||||
- [async_simple](https://github.com/alibaba/async_simple)
|
||||
- [openssl](https://www.openssl.org/) (optional)
|
||||
|
||||
### struct_pack
|
||||
### coro_http
|
||||
|
||||
TODO
|
||||
- [asio](https://think-async.com/Asio)
|
||||
- [async_simple](https://github.com/alibaba/async_simple)
|
||||
- [cinatra](https://github.com/qicosmos/cinatra)
|
||||
|
||||
## Benchmark
|
||||
### easylog
|
||||
|
||||
options:
|
||||
No dependency.
|
||||
|
||||
```bash
|
||||
./benchmark_client # [threads = hardware counts] [client_pre_thread = 20] [pipeline_size = 1] [host = 127.0.0.1] [port = 9000] [test_data_path = ./test_data/echo_test] [test_seconds = 30] [warm_up_seconds = 5]
|
||||
```
|
||||
|
||||
## Build Options
|
||||
|
||||
| option | description | default |
|
||||
| ----------------- | ------------------------------------------------ | ------- |
|
||||
| CMAKE_BUILD_TYPE | build type | Release |
|
||||
| BUILD_WITH_LIBCXX | Build with libc++ | OFF |
|
||||
| BUILD_EXAMPLES | Build examples | ON |
|
||||
| BUILD_BENCHMARK | Build benchmark | ON |
|
||||
| BUILD_UNIT_TESTS | Build unit test | ON |
|
||||
| USE_CONAN | Use conan package manager to handle dependencies | OFF |
|
||||
| ENABLE_SSL | Enable ssl support | OFF |
|
||||
| ENABLE_IO_URING | Enable io_uring support | OFF |
|
||||
|
||||
## Dependencies
|
||||
|
||||
We use doctest for unit test.
|
||||
All third-party dependencies are put in include/thirdparty.
|
||||
|
||||
### coro_rpc
|
||||
|
||||
- [struct_pack](https://github.com/alibaba/yalantinglibs)
|
||||
- [easylog](https://github.com/alibaba/yalantinglibs)
|
||||
- [asio](https://github.com/chriskohlhoff/asio)
|
||||
- openssl (optional)
|
||||
### struct_pack
|
||||
|
||||
No dependency.
|
||||
|
@ -373,26 +431,40 @@ No dependency.
|
|||
|
||||
- [iguana](https://github.com/qicosmos/iguana)
|
||||
|
||||
### struct_pb
|
||||
### struct_pb (optional)
|
||||
|
||||
TODO
|
||||
- [protobuf](https://protobuf.dev/)
|
||||
|
||||
### easylog
|
||||
### struct_xml
|
||||
|
||||
No dependency.
|
||||
- [iguana](https://github.com/qicosmos/iguana)
|
||||
|
||||
# How to generate document
|
||||
### struct_yaml
|
||||
|
||||
- [iguana](https://github.com/qicosmos/iguana)
|
||||
|
||||
## Benchmark
|
||||
|
||||
### coro_rpc
|
||||
options:
|
||||
|
||||
```bash
|
||||
./benchmark_client # [threads = hardware counts] [client_pre_thread = 20] [pipeline_size = 1] [host = 127.0.0.1] [port = 9000] [test_data_path = ./test_data/echo_test] [test_seconds = 30] [warm_up_seconds = 5]
|
||||
```
|
||||
|
||||
|
||||
## How to generate document
|
||||
|
||||
see [Build Website](https://github.com/alibaba/yalantinglibs/blob/main/website/README.md)
|
||||
|
||||
# How to Contribute
|
||||
## How to Contribute
|
||||
1. Create an issue in the issue template.
|
||||
2. Run tests and `git-clang-format HEAD^` locally for the change.
|
||||
3. Create a PR, fill in the PR template.
|
||||
4. Choose one or more reviewers from contributors: (e.g., qicosmos, poor-circle, PikachuHyA).
|
||||
5. Get approved and merged.
|
||||
|
||||
# License
|
||||
## License
|
||||
|
||||
yaLanTingLibs is distributed under the Apache License (Version 2.0)
|
||||
This product contains various third-party components under other open-source licenses.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Compile Standard
|
||||
message(STATUS "-------------COMPILE Setting-------------")
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
message(STATUS "CXX Standard: ${CMAKE_CXX_STANDARD}")
|
||||
|
@ -11,23 +12,47 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|||
|
||||
# libc++ or libstdc++&clang
|
||||
option(BUILD_WITH_LIBCXX "Build with libc++" OFF)
|
||||
message(STATUS "BUILD_WITH_LIBCXX: ${BUILD_WITH_LIBCXX}")
|
||||
if(BUILD_WITH_LIBCXX AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
message(STATUS "Build with libc++")
|
||||
else()
|
||||
message(STATUS "Build with libstdc++")
|
||||
endif()
|
||||
|
||||
# force use lld if your compiler is clang
|
||||
|
||||
# When using coro_rpc_client to send request, only remote function declarations are required.
|
||||
# In the examples, RPC function declaration and definition are divided.
|
||||
# However, clang + ld(gold linker) + '-g' will report 'undefined reference to xxx'.
|
||||
# So you can use lld when compiler is clang by this code:
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
add_link_options(-fuse-ld=lld)
|
||||
endif()
|
||||
|
||||
# ccache
|
||||
option(USE_CCACHE "use ccache to faster compile when develop" OFF)
|
||||
message(STATUS "USE_CCACHE: ${USE_CCACHE}")
|
||||
if (USE_CCACHE)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if (CCACHE_FOUND)
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER ccache)
|
||||
#set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) # ccache for link is useless
|
||||
message(STATUS "ccache found")
|
||||
else ()
|
||||
message(WARNING "ccache not found :you'd better use ccache to faster compile if you are developer")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# --------------------- GCC
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
|
||||
#-ftree-slp-vectorize with coroutine cause link error. disable it util gcc fix.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-tree-slp-vectorize")
|
||||
endif()
|
||||
# --------------------- Clang
|
||||
|
||||
# --------------------- Msvc
|
||||
# Resolves C1128 complained by MSVC: number of sections exceeded object file format limit: compile with /bigobj.
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")
|
||||
# Resolves C4737 complained by MSVC: C4737: Unable to perform required tail call. Performance may be degraded. "Release-Type only"
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/EHa>")
|
||||
endif()
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
message(STATUS "-------------PROJECT SETTING-------------")
|
||||
option(ENABLE_SSL "Enable ssl support" ON)
|
||||
message(STATUS "ENABLE_SSL: ${ENABLE_SSL}")
|
||||
if (ENABLE_SSL)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
add_compile_definitions(YLT_ENABLE_SSL)
|
||||
link_libraries(OpenSSL::SSL OpenSSL::Crypto)
|
||||
endif ()
|
||||
|
||||
option(ENABLE_PMR "Enable pmr support" OFF)
|
||||
message(STATUS "ENABLE_PMR: ${ENABLE_PMR}")
|
||||
if (ENABLE_PMR)
|
||||
add_compile_definitions(YLT_ENABLE_PMR IGUANA_ENABLE_PMR)
|
||||
endif ()
|
||||
|
||||
option(ENABLE_IO_URING "Enable io_uring" OFF)
|
||||
message(STATUS "ENABLE_IO_URING: ${ENABLE_IO_URING}")
|
||||
if (ENABLE_IO_URING)
|
||||
find_package(uring)
|
||||
if (NOT URING_FOUND)
|
||||
message(STATUS "liburing not found, the io_uring is disable")
|
||||
else()
|
||||
message(STATUS "Use IO_URING for all I/O in linux")
|
||||
add_compile_definitions(ASIO_HAS_IO_URING ASIO_DISABLE_EPOLL ASIO_HAS_FILE YLT_ENABLE_FILE_IO_URING)
|
||||
add_link_options(-luring)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_FILE_IO_URING "enable file io_uring" OFF)
|
||||
if (NOT ENABLE_IO_URING)
|
||||
message(STATUS "ENABLE_FILE_IO_URING: ${YLT_ENABLE_FILE_IO_URING}")
|
||||
endif()
|
||||
if(ENABLE_FILE_IO_URING)
|
||||
if (NOT ENABLE_IO_URING)
|
||||
if (NOT URING_FOUND)
|
||||
message(STATUS "liburing not found, the file io_uring is disable")
|
||||
else()
|
||||
message(STATUS "Enable io_uring for file I/O in linux")
|
||||
add_compile_definitions(ASIO_HAS_IO_URING ASIO_HAS_FILE YLT_ENABLE_FILE_IO_URING)
|
||||
add_link_options(-luring)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
option(ENABLE_STRUCT_PACK_UNPORTABLE_TYPE "enable struct_pack unportable type(like wchar_t)" OFF)
|
||||
message(STATUS "ENABLE_STRUCT_PACK_UNPORTABLE_TYPE: ${ENABLE_STRUCT_PACK_UNPORTABLE_TYPE}")
|
||||
if(ENABLE_STRUCT_PACK_UNPORTABLE_TYPE)
|
||||
add_compile_definitions(STRUCT_PACK_ENABLE_UNPORTABLE_TYPE)
|
||||
endif()
|
||||
|
||||
option(ENABLE_STRUCT_PACK_OPTIMIZE "enable struct_pack optimize(but cost more compile time)" OFF)
|
||||
message(STATUS "ENABLE_STRUCT_PACK_OPTIMIZE: ${ENABLE_STRUCT_PACK_OPTIMIZE}")
|
||||
if(ENABLE_STRUCT_PACK_OPTIMIZE)
|
||||
add_compile_definitions(ENABLE_STRUCT_PACK_OPTIMIZE)
|
||||
endif()
|
|
@ -1,8 +0,0 @@
|
|||
# 3rd-party package load
|
||||
option(USE_CONAN "Use conan package manager" OFF)
|
||||
if(USE_CONAN)
|
||||
message(STATUS "Use conan package manager")
|
||||
find_package(asio REQUIRED)
|
||||
else()
|
||||
add_subdirectory(${yaLanTingLibs_SOURCE_DIR}/thirdparty)
|
||||
endif()
|
|
@ -1,17 +1,22 @@
|
|||
message(STATUS "-------------DEVELOP SETTING-------------")
|
||||
# extra
|
||||
option(BUILD_EXAMPLES "Build examples" ON)
|
||||
message(STATUS "BUILD_EXAMPLES: ${BUILD_EXAMPLES}")
|
||||
|
||||
# bench test
|
||||
option(BUILD_BENCHMARK "Build benchmark" ON)
|
||||
message(STATUS "BUILD_BENCHMARK: ${BUILD_BENCHMARK}")
|
||||
|
||||
# unit test
|
||||
option(BUILD_UNIT_TESTS "Build unit tests" ON)
|
||||
message(STATUS "BUILD_UNIT_TESTS: ${BUILD_UNIT_TESTS}")
|
||||
if(BUILD_UNIT_TESTS)
|
||||
enable_testing()
|
||||
endif()
|
||||
|
||||
# coverage test
|
||||
option(COVERAGE_TEST "Build with unit test coverage" OFF)
|
||||
message(STATUS "COVERAGE_TEST: ${COVERAGE_TEST}")
|
||||
if(COVERAGE_TEST)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage --coverage")
|
||||
|
@ -20,6 +25,15 @@ if(COVERAGE_TEST)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# generator benchmark test data
|
||||
option(GENERATE_BENCHMARK_DATA "Generate benchmark data" ON)
|
||||
message(STATUS "GENERATE_BENCHMARK_DATA: ${GENERATE_BENCHMARK_DATA}")
|
||||
|
||||
|
||||
# Enable coro_rpc user define protocol example
|
||||
option(CORO_RPC_USE_OTHER_RPC "coro_rpc extend to support other rpc" OFF)
|
||||
message(STATUS "CORO_RPC_USE_OTHER_RPC: ${CORO_RPC_USE_OTHER_RPC}")
|
||||
|
||||
# Enable address sanitizer
|
||||
option(ENABLE_SANITIZER "Enable sanitizer(Debug+Gcc/Clang/AppleClang)" ON)
|
||||
if(ENABLE_SANITIZER AND NOT MSVC)
|
||||
|
@ -30,8 +44,6 @@ if(ENABLE_SANITIZER AND NOT MSVC)
|
|||
else()
|
||||
message(WARNING "sanitizer is no supported with current tool-chains")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Sanitizer supported only for debug type")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
# install public header files
|
||||
message(STATUS "-------------INSTALL SETTING-------------")
|
||||
option(INSTALL_THIRDPARTY "Install thirdparty" ON)
|
||||
message(STATUS "INSTALL_THIRDPARTY: " ${INSTALL_THIRDPARTY})
|
||||
option(INSTALL_INDEPENDENT_THIRDPARTY "Install independent thirdparty" ON)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${yaLanTingLibs_BINARY_DIR}/cmake/yalantinglibsConfigVersion.cmake"
|
||||
|
@ -7,41 +11,30 @@ write_basic_package_version_file(
|
|||
)
|
||||
set(ConfigPackageLocation lib/cmake/yalantinglibs)
|
||||
|
||||
configure_file(cmake/yalantinglibsConfig.cmake.in
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/yalantinglibsConfig.cmake"
|
||||
COPYONLY
|
||||
)
|
||||
#install(DIRECTORY "${yaLanTingLibs_SOURCE_DIR}/include/" DESTINATION include/yalantinglibs)
|
||||
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/yalantinglibsConfig.cmake"
|
||||
"${yaLanTingLibs_BINARY_DIR}/cmake/yalantinglibsConfigVersion.cmake"
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
function(ylt_install target)
|
||||
cmake_parse_arguments(ylt_install_lib " " "NAME" "EXPORT" ${ARGN})
|
||||
set(_export_name ${target}Targets)
|
||||
if (ylt_install_lib_NAME)
|
||||
set(_export_name ${ylt_install_lib_NAME})
|
||||
endif ()
|
||||
install(
|
||||
TARGETS ${target}
|
||||
EXPORT ${_export_name}
|
||||
add_library(yalantinglibs INTERFACE)
|
||||
install(TARGETS yalantinglibs
|
||||
EXPORT yalantinglibsTargets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
${target}ConfigVersion.cmake
|
||||
VERSION ${yaLanTingLibs_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
install(
|
||||
EXPORT ${_export_name}
|
||||
FILE ${target}Targets.cmake
|
||||
install(EXPORT yalantinglibsTargets
|
||||
FILE yalantinglibsConfig.cmake
|
||||
NAMESPACE yalantinglibs::
|
||||
DESTINATION ${ConfigPackageLocation}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
install(DIRECTORY "${yaLanTingLibs_SOURCE_DIR}/include/" DESTINATION include REGEX "${yaLanTingLibs_SOURCE_DIR}/include/ylt/thirdparty" EXCLUDE)
|
||||
|
||||
if (INSTALL_THIRDPARTY)
|
||||
message(STATUS "INSTALL_INDEPENDENT_THIRDPARTY: " ${INSTALL_INDEPENDENT_THIRDPARTY})
|
||||
if (INSTALL_INDEPENDENT_THIRDPARTY)
|
||||
install(DIRECTORY "${yaLanTingLibs_SOURCE_DIR}/include/ylt/thirdparty/" DESTINATION include)
|
||||
else()
|
||||
install(DIRECTORY "${yaLanTingLibs_SOURCE_DIR}/include/ylt/thirdparty/" DESTINATION include/ylt/thirdparty)
|
||||
target_include_directories(yalantinglibs INTERFACE
|
||||
$<INSTALL_INTERFACE:include/ylt/thirdparty>
|
||||
)
|
||||
endif()
|
||||
endif()
|
|
@ -1,42 +0,0 @@
|
|||
# module-list
|
||||
set(yLT_ALL_PROJECTS "struct_pack;struct_pb;struct_json;struct_xml;struct_yaml;coro_rpc;easylog;coro_http;coro_file")
|
||||
# separate
|
||||
option(Build_ylt_struct_pack "Build struct_pack" ON)
|
||||
option(Build_ylt_struct_pb "Build struct_pb" ON)
|
||||
option(Build_ylt_struct_json "Build struct_json" ON)
|
||||
option(Build_ylt_struct_xml "Build struct_xml" ON)
|
||||
option(Build_ylt_struct_yaml "Build struct_yaml" ON)
|
||||
option(Build_ylt_coro_rpc "Build coro_rpc" ON)
|
||||
option(Build_ylt_easylog "Build easylog" ON)
|
||||
option(Build_ylt_coro_http "Build coro_http" ON)
|
||||
option(Build_ylt_coro_file "Build coro_file" ON)
|
||||
|
||||
foreach (proj ${yLT_ALL_PROJECTS})
|
||||
set(build_proj "Build_ylt_${proj}")
|
||||
if (${build_proj})
|
||||
list(APPEND yLT_ENABLE_PROJECTS ${proj})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
message(STATUS "yLT_ENABLE_PROJECTS: ${yLT_ENABLE_PROJECTS}")
|
||||
|
||||
foreach (module ${yLT_ENABLE_PROJECTS})
|
||||
set(module_location ${yaLanTingLibs_SOURCE_DIR}/src/${module})
|
||||
if (EXISTS ${module_location})
|
||||
add_subdirectory(${module_location})
|
||||
if ("${yaLanTingLibs_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
|
||||
if (BUILD_UNIT_TESTS AND EXISTS "${module_location}/tests")
|
||||
message(STATUS "ylt_add_tests_${module}")
|
||||
add_subdirectory(${module_location}/tests)
|
||||
endif ()
|
||||
if (BUILD_BENCHMARK AND EXISTS "${module_location}/benchmark")
|
||||
message(STATUS "ylt_add_benchmark_${module}")
|
||||
add_subdirectory(${module_location}/benchmark)
|
||||
endif ()
|
||||
if (BUILD_EXAMPLES AND EXISTS "${module_location}/examples")
|
||||
message(STATUS "ylt_add_example_${module}")
|
||||
add_subdirectory(${module_location}/examples)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endforeach ()
|
|
@ -1,15 +0,0 @@
|
|||
# --------------------- Gcc
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
|
||||
#-ftree-slp-vectorize with coroutine cause link error. disable it util gcc fix.
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-tree-slp-vectorize")
|
||||
endif()
|
||||
# --------------------- Clang
|
||||
|
||||
# --------------------- Msvc
|
||||
# Resolves C1128 complained by MSVC: number of sections exceeded object file format limit: compile with /bigobj.
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")
|
||||
# Resolves C4737 complained by MSVC: C4737: Unable to perform required tail call. Performance may be degraded. "Release-Type only"
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/EHa>")
|
||||
endif()
|
|
@ -165,7 +165,7 @@ function(protobuf_generate_struct_pb SRCS HDRS)
|
|||
set(_outvar)
|
||||
protobuf_generate_modified(${_append_arg} ${_descriptors}
|
||||
LANGUAGE struct_pb EXPORT_MACRO ${protobuf_generate_struct_pb_EXPORT_MACRO}
|
||||
PLUGIN $<TARGET_FILE:yalantinglibs::protoc-gen-struct_pb>
|
||||
PLUGIN $<TARGET_FILE:protoc-gen-struct_pb>
|
||||
OUT_VAR _outvar ${_import_arg} PROTOS ${_proto_files}
|
||||
PROTOC_OPTION ${_opt}
|
||||
)
|
||||
|
@ -217,7 +217,7 @@ function(target_protos_struct_pb target)
|
|||
protobuf_generate_modified(
|
||||
TARGET ${target}
|
||||
LANGUAGE struct_pb EXPORT_MACRO ${target_protos_struct_pb_EXPORT_MACRO}
|
||||
PLUGIN $<TARGET_FILE:yalantinglibs::protoc-gen-struct_pb>
|
||||
PLUGIN $<TARGET_FILE:protoc-gen-struct_pb>
|
||||
${_import_arg} PROTOS ${_proto_files}
|
||||
PROTOC_OPTION ${_opt}
|
||||
)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
file(GLOB children src/*)
|
||||
foreach(child ${children})
|
||||
if(BUILD_UNIT_TESTS AND EXISTS ${child}/examples)
|
||||
add_subdirectory(${child}/examples)
|
||||
endif()
|
||||
if(BUILD_BENCHMARK AND EXISTS ${child}/tests)
|
||||
add_subdirectory(${child}/tests)
|
||||
endif()
|
||||
if(BUILD_EXAMPLES AND EXISTS ${child}/benchmark)
|
||||
add_subdirectory(${child}/benchmark)
|
||||
endif()
|
||||
endforeach()
|
||||
add_subdirectory(src/struct_pb)
|
|
@ -12,36 +12,3 @@ int main()
|
|||
)
|
||||
unset(CMAKE_REQUIRED_FLAGS)
|
||||
endmacro()
|
||||
|
||||
# Enable address sanitizer for a target (gcc/clang only)
|
||||
function(target_enable_sanitizer target_name)
|
||||
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
|
||||
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
|
||||
endif()
|
||||
message(STATUS "Address sanitizer enabled")
|
||||
target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined)
|
||||
target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow)
|
||||
target_compile_options(${target_name} PRIVATE -fno-sanitize-recover=all)
|
||||
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
|
||||
# target_link_libraries(${target_name} PRIVATE -fsanitize=address,undefined -fuse-ld=gold) #
|
||||
endfunction()
|
||||
|
||||
# Turn on warnings on the given target
|
||||
function(target_enable_warnings target_name)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
list(APPEND MSVC_OPTIONS "/W3")
|
||||
if(MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
|
||||
list(APPEND MSVC_OPTIONS "/WX")
|
||||
endif()
|
||||
endif()
|
||||
target_compile_options(
|
||||
${target_name}
|
||||
PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wconversion
|
||||
-pedantic
|
||||
-Werror
|
||||
-Wfatal-errors>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
|
||||
endfunction()
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
include(CMakeFindDependencyMacro)
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/struct_packTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/struct_packTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::struct_pack")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/struct_pbTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/struct_pbTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::struct_pb")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/protoc-gen-struct_pbTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/protoc-gen-struct_pbTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::protoc-gen-struct_pb")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/struct_pb.cmake")
|
||||
message(STATUS "Now you can use cmake helper function protobuf_generate_struct_pb to generate xx.struct_pb.cc xx.struct_pb.h")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/struct_jsonTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/struct_jsonTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::struct_json")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/struct_xmlTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/struct_xmlTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::struct_xml")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/struct_yamlTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/struct_yamlTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::struct_yaml")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/easylogTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/easylogTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::easylog")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/coro_rpcTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/coro_rpcTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::coro_rpc")
|
||||
endif ()
|
||||
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/coro_httpTargets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/coro_httpTargets.cmake")
|
||||
message(STATUS "Imported target: yalantinglibs::coro_http")
|
||||
endif ()
|
57
conanfile.py
57
conanfile.py
|
@ -1,57 +0,0 @@
|
|||
from conans import ConanFile
|
||||
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
|
||||
|
||||
|
||||
class CoroRpcConan(ConanFile):
|
||||
name = "coro_rpc"
|
||||
version = "0.1.0"
|
||||
|
||||
# Binary configuration
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
options = {
|
||||
"shared": [True, False],
|
||||
"fPIC": [True, False],
|
||||
"BUILD_WITH_LIBCXX": [True, False],
|
||||
"BUILD_EXAMPLES": [True, False],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"BUILD_WITH_LIBCXX": True,
|
||||
"BUILD_EXAMPLES": False,
|
||||
}
|
||||
|
||||
# Sources are located in the same place as this recipe, copy them to the recipe
|
||||
exports_sources = "CMakeLists.txt", \
|
||||
"coro_io/*", "examples/*", "easylog/*", "coro_rpc/*", "struct_pack/*", "util/*", "tests/*"
|
||||
|
||||
def requirements(self):
|
||||
self.requires("asio/1.23.0")
|
||||
|
||||
def config_options(self):
|
||||
if self.settings.os == "Windows":
|
||||
del self.options.fPIC
|
||||
|
||||
def layout(self):
|
||||
cmake_layout(self)
|
||||
|
||||
def generate(self):
|
||||
tc = CMakeToolchain(self)
|
||||
tc.generate()
|
||||
deps = CMakeDeps(self)
|
||||
deps.generate()
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
variables = {
|
||||
"USE_CONAN": "ON"
|
||||
}
|
||||
cmake.configure(variables)
|
||||
cmake.build()
|
||||
|
||||
def package(self):
|
||||
cmake = CMake(self)
|
||||
cmake.install()
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = ["hello"]
|
|
@ -32,11 +32,11 @@ make -j test_rpc
|
|||
# add %m to fix the bug on ARM
|
||||
# https://groups.google.com/g/llvm-dev/c/oaA58fbNMGg
|
||||
# https://github.com/llvm/llvm-project/issues/50966
|
||||
export LLVM_PROFILE_FILE="test_rpc-%m.profraw"
|
||||
export LLVM_PROFILE_FILE="coro_rpc_test-%m.profraw"
|
||||
ls
|
||||
cd tests
|
||||
./test_rpc
|
||||
llvm-profdata merge -sparse test_rpc-*.profraw -o test_rpc.profdata
|
||||
llvm-cov show ./test_rpc -instr-profile=test_rpc.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="async_simple|thirdparty|tests|asio|util|logging|struct_pack" -show-instantiations=false
|
||||
llvm-profdata merge -sparse coro_rpc_test-*.profraw -o coro_rpc_test.profdata
|
||||
llvm-cov show ./coro_rpc_test -instr-profile=test_rpc.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="async_simple|thirdparty|tests|asio|util|logging|struct_pack" -show-instantiations=false
|
||||
echo 'Done!!!'
|
||||
fi
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#pragma once
|
||||
#include <iguana/xml_reader.hpp>
|
||||
|
||||
namespace struct_xml {
|
||||
|
||||
template <int Flags = 0, typename T>
|
||||
inline bool from_xml(T &&t, char *buf) {
|
||||
return iguana::from_xml<Flags>(std::forward<T>(t), buf);
|
||||
}
|
||||
|
||||
template <int Flags = 0, typename T>
|
||||
inline bool from_xml(T &&t, const std::string &str) {
|
||||
return from_xml<Flags>(std::forward<T>(t), str.data());
|
||||
}
|
||||
|
||||
template <int Flags = 0, typename T>
|
||||
inline bool from_xml(T &&t, std::string_view str) {
|
||||
return from_xml<Flags>(std::forward<T>(t), str.data());
|
||||
}
|
||||
|
||||
inline std::string get_last_read_err() { return iguana::get_last_read_err(); }
|
||||
|
||||
using any_t = iguana::any_t;
|
||||
} // namespace struct_xml
|
|
@ -1,14 +0,0 @@
|
|||
#pragma once
|
||||
#include <iguana/xml_writer.hpp>
|
||||
|
||||
namespace struct_xml {
|
||||
template <typename Stream, typename T>
|
||||
inline void to_xml(T &&t, Stream &s) {
|
||||
iguana::to_xml(std::forward<T>(t), s);
|
||||
}
|
||||
|
||||
template <int Flags = 0, typename Stream, typename T>
|
||||
inline bool to_xml_pretty(T &&t, Stream &s) {
|
||||
return iguana::to_xml_pretty<Flags>(std::forward<T>(t), s);
|
||||
}
|
||||
} // namespace struct_xml
|
|
@ -1,15 +0,0 @@
|
|||
#pragma once
|
||||
#include <iguana/yaml_reader.hpp>
|
||||
|
||||
namespace struct_yaml {
|
||||
|
||||
template <typename T, iguana::string_t View>
|
||||
inline void from_yaml(T &value, const View &view) {
|
||||
iguana::from_yaml(value, view);
|
||||
}
|
||||
|
||||
template <typename T, iguana::string_t View>
|
||||
inline void from_yaml(T &value, const View &view, std::error_code &ec) {
|
||||
iguana::from_yaml(value, view, ec);
|
||||
}
|
||||
} // namespace struct_yaml
|
|
@ -1,9 +0,0 @@
|
|||
#pragma once
|
||||
#include <iguana/yaml_writer.hpp>
|
||||
|
||||
namespace struct_yaml {
|
||||
template <typename Stream, typename T>
|
||||
inline void to_yaml(T &&t, Stream &s, size_t min_spaces = 0) {
|
||||
iguana::to_yaml(std::forward<T>(t), s, min_spaces);
|
||||
}
|
||||
} // namespace struct_yaml
|
File diff suppressed because it is too large
Load Diff
|
@ -14,6 +14,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
#define CINATRA_ENABLE_SSL
|
||||
#endif
|
||||
#include <cinatra/coro_http_client.hpp>
|
||||
|
||||
namespace coro_http {
|
|
@ -14,13 +14,14 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <random>
|
||||
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
#include "client_pool.hpp"
|
||||
#include "coro_io/io_context_pool.hpp"
|
||||
#include "io_context_pool.hpp"
|
||||
namespace coro_io {
|
||||
|
||||
enum class load_blance_algorithm {
|
|
@ -14,6 +14,17 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <async_simple/Executor.h>
|
||||
#include <async_simple/Promise.h>
|
||||
#include <async_simple/Try.h>
|
||||
#include <async_simple/Unit.h>
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
#include <async_simple/coro/Sleep.h>
|
||||
#include <async_simple/coro/SpinLock.h>
|
||||
|
||||
#include <asio/io_context.hpp>
|
||||
#include <asio/steady_timer.hpp>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
|
@ -27,20 +38,11 @@
|
|||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <ylt/util/expected.hpp>
|
||||
|
||||
#include "asio/io_context.hpp"
|
||||
#include "asio/steady_timer.hpp"
|
||||
#include "async_simple/Executor.h"
|
||||
#include "async_simple/Promise.h"
|
||||
#include "async_simple/Try.h"
|
||||
#include "async_simple/Unit.h"
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
#include "async_simple/coro/Sleep.h"
|
||||
#include "async_simple/coro/SpinLock.h"
|
||||
#include "coro_io/client_queue.hpp"
|
||||
#include "coro_io/coro_io.hpp"
|
||||
#include "coro_io/io_context_pool.hpp"
|
||||
#include "util/expected.hpp"
|
||||
#include "detail/client_queue.hpp"
|
||||
#include "coro_io.hpp"
|
||||
#include "io_context_pool.hpp"
|
||||
namespace coro_io {
|
||||
|
||||
template <typename client_t, typename io_context_pool_t>
|
|
@ -14,20 +14,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <asio/io_context.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include "async_simple/Promise.h"
|
||||
#include "async_simple/Traits.h"
|
||||
#include "async_simple/coro/FutureAwaiter.h"
|
||||
#include "io_context_pool.hpp"
|
||||
#if defined(ENABLE_FILE_IO_URING)
|
||||
#include <async_simple/Promise.h>
|
||||
#include <async_simple/Traits.h>
|
||||
#include <async_simple/coro/FutureAwaiter.h>
|
||||
#if defined(YLT_ENABLE_FILE_IO_URING)
|
||||
#include <asio/random_access_file.hpp>
|
||||
#include <asio/stream_file.hpp>
|
||||
#endif
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
|
||||
#include <asio/error.hpp>
|
||||
#include <asio/io_context.hpp>
|
||||
#include <cstddef>
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -36,12 +38,11 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "asio/error.hpp"
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
#include "coro_io.hpp"
|
||||
#include "io_context_pool.hpp"
|
||||
|
||||
namespace coro_io {
|
||||
#if defined(ENABLE_FILE_IO_URING)
|
||||
#if defined(YLT_ENABLE_FILE_IO_URING)
|
||||
inline asio::file_base::flags default_flags() {
|
||||
return asio::stream_file::read_write | asio::stream_file::append |
|
||||
asio::stream_file::create;
|
||||
|
@ -52,7 +53,7 @@ enum class open_mode { read, write };
|
|||
|
||||
class coro_file {
|
||||
public:
|
||||
#if defined(ENABLE_FILE_IO_URING)
|
||||
#if defined(YLT_ENABLE_FILE_IO_URING)
|
||||
coro_file(
|
||||
std::string_view filepath, open_mode flags = open_mode::read,
|
||||
coro_io::ExecutorWrapper<>* executor = coro_io::get_global_executor())
|
||||
|
@ -97,7 +98,7 @@ class coro_file {
|
|||
#endif
|
||||
|
||||
bool is_open() {
|
||||
#if defined(ENABLE_FILE_IO_URING)
|
||||
#if defined(YLT_ENABLE_FILE_IO_URING)
|
||||
return stream_file_ && stream_file_->is_open();
|
||||
#else
|
||||
return stream_file_ && stream_file_->is_open();
|
||||
|
@ -114,7 +115,7 @@ class coro_file {
|
|||
return size;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_FILE_IO_URING)
|
||||
#if defined(YLT_ENABLE_FILE_IO_URING)
|
||||
async_simple::coro::Lazy<std::pair<std::error_code, size_t>> async_read(
|
||||
char* data, size_t size) {
|
||||
size_t left_size = size;
|
||||
|
@ -240,7 +241,7 @@ class coro_file {
|
|||
#endif
|
||||
|
||||
private:
|
||||
#if defined(ENABLE_FILE_IO_URING)
|
||||
#if defined(YLT_ENABLE_FILE_IO_URING)
|
||||
std::unique_ptr<asio::stream_file> stream_file_;
|
||||
std::atomic<size_t> seek_offset_ = 0;
|
||||
#else
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,16 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <async_simple/Executor.h>
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
#include <async_simple/coro/Sleep.h>
|
||||
#include <async_simple/coro/SyncAwait.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
|
||||
#include "async_simple/Executor.h"
|
||||
#include "async_simple/coro/Sleep.h"
|
||||
|
||||
#if defined(ENABLE_SSL) || defined(CINATRA_ENABLE_SSL)
|
||||
#if defined(YLT_ENABLE_SSL) || defined(CINATRA_ENABLE_SSL)
|
||||
#include <asio/ssl.hpp>
|
||||
#endif
|
||||
|
||||
|
@ -32,6 +29,8 @@
|
|||
#include <asio/read.hpp>
|
||||
#include <asio/read_until.hpp>
|
||||
#include <asio/write.hpp>
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
|
||||
#include "io_context_pool.hpp"
|
||||
|
||||
|
@ -233,7 +232,7 @@ inline async_simple::coro::Lazy<void> async_close(Socket &socket) noexcept {
|
|||
});
|
||||
}
|
||||
|
||||
#if defined(ENABLE_SSL) || defined(CINATRA_ENABLE_SSL)
|
||||
#if defined(YLT_ENABLE_SSL) || defined(CINATRA_ENABLE_SSL)
|
||||
inline async_simple::coro::Lazy<std::error_code> async_handshake(
|
||||
auto &ssl_stream, asio::ssl::stream_base::handshake_type type) noexcept {
|
||||
callback_awaitor<std::error_code> awaitor;
|
|
@ -1,8 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <atomic>
|
||||
#include <iterator>
|
||||
|
||||
#include "util/concurrentqueue.h"
|
||||
#include "ylt/util/concurrentqueue.h"
|
||||
namespace coro_io::detail {
|
||||
template <typename client_t>
|
||||
class client_queue {
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <async_simple/Executor.h>
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
|
||||
#include <asio/io_context.hpp>
|
||||
#include <asio/post.hpp>
|
||||
|
@ -26,8 +27,6 @@
|
|||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
|
||||
namespace coro_io {
|
||||
|
||||
template <typename ExecutorImpl = asio::io_context::executor_type>
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,4 +14,4 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include "coro_rpc/coro_rpc_client.hpp"
|
||||
#include "impl/coro_rpc_client.hpp"
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -15,4 +15,4 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <coro_rpc/coro_rpc/protocol/coro_rpc_protocol.hpp>
|
||||
#include "impl/protocol/coro_rpc_protocol.hpp"
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,5 +14,5 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <coro_rpc/coro_rpc/coro_rpc_server.hpp>
|
||||
#include <coro_rpc/coro_rpc/default_config/coro_rpc_config.hpp>
|
||||
#include "impl/coro_rpc_server.hpp"
|
||||
#include "impl/default_config/coro_rpc_config.hpp"
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -15,11 +15,10 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <easylog/easylog.h>
|
||||
|
||||
#include <filesystem>
|
||||
#include <ylt/easylog.hpp>
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
#include <asio/ssl.hpp>
|
||||
#endif
|
||||
|
||||
|
@ -55,7 +54,7 @@ inline bool file_exists(auto &path) {
|
|||
return false;
|
||||
};
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
/*!
|
||||
* Initialize SSL Context `context` with SSL Config `conf`
|
||||
*
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -15,6 +15,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
|
||||
#include <any>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
@ -22,11 +24,10 @@
|
|||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <ylt/easylog.hpp>
|
||||
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
#include "coro_connection.hpp"
|
||||
#include "easylog/easylog.h"
|
||||
#include "util/type_traits.h"
|
||||
#include "ylt/util/type_traits.h"
|
||||
|
||||
namespace coro_rpc {
|
||||
/*!
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,8 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <async_simple/Executor.h>
|
||||
#include <async_simple/coro/SyncAwait.h>
|
||||
|
||||
#include <any>
|
||||
#include <array>
|
||||
#include <asio/buffer.hpp>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <future>
|
||||
|
@ -25,12 +29,9 @@
|
|||
#include <utility>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#include <ylt/easylog.hpp>
|
||||
|
||||
#include "asio/buffer.hpp"
|
||||
#include "async_simple/Executor.h"
|
||||
#include "async_simple/coro/SyncAwait.h"
|
||||
#include "coro_io/coro_io.hpp"
|
||||
#include "easylog/easylog.h"
|
||||
#include "ylt/coro_io/coro_io.hpp"
|
||||
#ifdef UNIT_TEST_INJECT
|
||||
#include "inject_action.hpp"
|
||||
#endif
|
||||
|
@ -103,7 +104,7 @@ class coro_connection : public std::enable_shared_from_this<coro_connection> {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
void init_ssl(asio::ssl::context &ssl_ctx) {
|
||||
ssl_stream_ = std::make_unique<asio::ssl::stream<asio::ip::tcp::socket &>>(
|
||||
socket_, ssl_ctx);
|
||||
|
@ -114,7 +115,7 @@ class coro_connection : public std::enable_shared_from_this<coro_connection> {
|
|||
template <typename rpc_protocol>
|
||||
async_simple::coro::Lazy<void> start(
|
||||
typename rpc_protocol::router &router) noexcept {
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
if (use_ssl_) {
|
||||
assert(ssl_stream_);
|
||||
ELOGV(INFO, "begin to handshake conn_id %d", conn_id_);
|
||||
|
@ -135,7 +136,7 @@ class coro_connection : public std::enable_shared_from_this<coro_connection> {
|
|||
else {
|
||||
#endif
|
||||
co_await start_impl<rpc_protocol>(router, socket_);
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -394,7 +395,7 @@ class coro_connection : public std::enable_shared_from_this<coro_connection> {
|
|||
#endif
|
||||
std::array<asio::const_buffer, 2> buffers{asio::buffer(msg.first),
|
||||
asio::buffer(msg.second)};
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
if (use_ssl_) {
|
||||
assert(ssl_stream_);
|
||||
ret = co_await coro_io::async_write(*ssl_stream_, buffers);
|
||||
|
@ -402,7 +403,7 @@ class coro_connection : public std::enable_shared_from_this<coro_connection> {
|
|||
else {
|
||||
#endif
|
||||
ret = co_await coro_io::async_write(socket_, buffers);
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
}
|
||||
#endif
|
||||
if (ret.first)
|
||||
|
@ -509,7 +510,7 @@ class coro_connection : public std::enable_shared_from_this<coro_connection> {
|
|||
|
||||
std::any tag_;
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
std::unique_ptr<asio::ssl::stream<asio::ip::tcp::socket &>> ssl_stream_ =
|
||||
nullptr;
|
||||
bool use_ssl_ = false;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,7 +16,11 @@
|
|||
#pragma once
|
||||
#include <async_simple/Future.h>
|
||||
#include <async_simple/coro/FutureAwaiter.h>
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
#include <async_simple/coro/SyncAwait.h>
|
||||
|
||||
#include <asio/io_context.hpp>
|
||||
#include <asio/ip/tcp.hpp>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
@ -30,24 +34,19 @@
|
|||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <variant>
|
||||
#include <ylt/easylog.hpp>
|
||||
|
||||
#include "asio/io_context.hpp"
|
||||
#include "asio/ip/tcp.hpp"
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
#include "async_simple/coro/SyncAwait.h"
|
||||
#include "common_service.hpp"
|
||||
#include "coro_io/coro_io.hpp"
|
||||
#include "coro_io/io_context_pool.hpp"
|
||||
#include "coro_rpc/coro_rpc/context.hpp"
|
||||
#include "coro_rpc/coro_rpc/protocol/coro_rpc_protocol.hpp"
|
||||
#include "easylog/easylog.h"
|
||||
#include "context.hpp"
|
||||
#include "expected.hpp"
|
||||
#include "struct_pack/struct_pack.hpp"
|
||||
#include "util/function_name.h"
|
||||
#include "util/type_traits.h"
|
||||
#include "util/utils.hpp"
|
||||
#include "protocol/coro_rpc_protocol.hpp"
|
||||
#include "ylt/coro_io/coro_io.hpp"
|
||||
#include "ylt/coro_io/io_context_pool.hpp"
|
||||
#include "ylt/struct_pack.hpp"
|
||||
#include "ylt/util/function_name.h"
|
||||
#include "ylt/util/type_traits.h"
|
||||
#include "ylt/util/utils.hpp"
|
||||
#ifdef UNIT_TEST_INJECT
|
||||
#include "coro_io/coro_io.hpp"
|
||||
#include "inject_action.hpp"
|
||||
#endif
|
||||
|
||||
|
@ -79,7 +78,7 @@ template <typename T>
|
|||
using rpc_return_type_t = typename rpc_return_type<T>::type;
|
||||
/*!
|
||||
* ```cpp
|
||||
* #include <coro_rpc/coro_rpc_client.hpp>
|
||||
* #include <ylt/coro_rpc/coro_rpc_client.hpp>
|
||||
*
|
||||
* using namespace coro_rpc;
|
||||
* using namespace async_simple::coro;
|
||||
|
@ -112,7 +111,7 @@ class coro_rpc_client {
|
|||
std::chrono::milliseconds{5000};
|
||||
std::string host;
|
||||
std::string port;
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
std::filesystem::path ssl_cert_path;
|
||||
std::string ssl_domain;
|
||||
#endif
|
||||
|
@ -161,7 +160,7 @@ class coro_rpc_client {
|
|||
|
||||
[[nodiscard]] bool init_config(const config &conf) {
|
||||
config_ = conf;
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
return init_ssl_impl();
|
||||
#else
|
||||
return true;
|
||||
|
@ -243,7 +242,7 @@ class coro_rpc_client {
|
|||
return connect();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
|
||||
[[nodiscard]] bool init_ssl(std::string_view cert_base_path,
|
||||
std::string_view cert_file_name,
|
||||
|
@ -303,7 +302,7 @@ class coro_rpc_client {
|
|||
}
|
||||
|
||||
rpc_result<R, coro_rpc_protocol> ret;
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
if (!ssl_init_ret_) {
|
||||
ret = rpc_result<R, coro_rpc_protocol>{
|
||||
unexpect_t{}, coro_rpc_protocol::rpc_error{std::errc::not_connected,
|
||||
|
@ -320,7 +319,7 @@ class coro_rpc_client {
|
|||
.via(&executor)
|
||||
.detach();
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
if (!config_.ssl_cert_path.empty()) {
|
||||
assert(ssl_stream_);
|
||||
ret = co_await call_impl<func>(*ssl_stream_, std::move(args)...);
|
||||
|
@ -328,7 +327,7 @@ class coro_rpc_client {
|
|||
else {
|
||||
#endif
|
||||
ret = co_await call_impl<func>(socket_, std::move(args)...);
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -370,8 +369,9 @@ class coro_rpc_client {
|
|||
static bool is_ok(std::errc ec) noexcept { return ec == std::errc{}; }
|
||||
[[nodiscard]] async_simple::coro::Lazy<std::errc> connect(
|
||||
bool is_reconnect = false) {
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
if (!ssl_init_ret_) {
|
||||
std::cout << "ssl_init_ret_: " << ssl_init_ret_ << std::endl;
|
||||
co_return std::errc::not_connected;
|
||||
}
|
||||
#endif
|
||||
|
@ -411,7 +411,7 @@ class coro_rpc_client {
|
|||
co_return std::errc::timed_out;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
if (!config_.ssl_cert_path.empty()) {
|
||||
assert(ssl_stream_);
|
||||
auto shake_ec = co_await coro_io::async_handshake(
|
||||
|
@ -426,7 +426,7 @@ class coro_rpc_client {
|
|||
|
||||
co_return std::errc{};
|
||||
};
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
[[nodiscard]] bool init_ssl_impl() {
|
||||
try {
|
||||
ssl_init_ret_ = false;
|
||||
|
@ -798,7 +798,7 @@ class coro_rpc_client {
|
|||
std::vector<std::byte> read_buf_;
|
||||
config config_;
|
||||
constexpr static std::size_t default_read_buf_size_ = 256;
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
asio::ssl::context ssl_ctx_{asio::ssl::context::sslv23};
|
||||
std::unique_ptr<asio::ssl::stream<asio::ip::tcp::socket &>> ssl_stream_;
|
||||
bool ssl_init_ret_ = true;
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,6 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
|
||||
#include <asio/dispatch.hpp>
|
||||
#include <asio/error_code.hpp>
|
||||
#include <asio/io_context.hpp>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <cstdint>
|
||||
|
@ -25,20 +30,16 @@
|
|||
#include <system_error>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <ylt/easylog.hpp>
|
||||
|
||||
#include "asio/dispatch.hpp"
|
||||
#include "asio/error_code.hpp"
|
||||
#include "asio/io_context.hpp"
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
#include "common_service.hpp"
|
||||
#include "coro_connection.hpp"
|
||||
#include "coro_io/coro_io.hpp"
|
||||
#include "coro_io/io_context_pool.hpp"
|
||||
#include "easylog/easylog.h"
|
||||
#include "ylt/coro_io/coro_io.hpp"
|
||||
#include "ylt/coro_io/io_context_pool.hpp"
|
||||
namespace coro_rpc {
|
||||
/*!
|
||||
* ```cpp
|
||||
* #include <coro_rpc/coro_rpc_server.hpp>
|
||||
* #include <ylt/coro_rpc/coro_rpc_server.hpp>
|
||||
* inline std::string hello_coro_rpc() { return "hello coro_rpc"; }
|
||||
* int main(){
|
||||
* register_handler<hello_coro_rpc>();
|
||||
|
@ -87,7 +88,7 @@ class coro_rpc_server_base {
|
|||
stop();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
void init_ssl_context(const ssl_configure &conf) {
|
||||
use_ssl_ = init_ssl_context_helper(context_, conf);
|
||||
}
|
||||
|
@ -381,7 +382,7 @@ class coro_rpc_server_base {
|
|||
}
|
||||
|
||||
async_simple::coro::Lazy<void> start_one(auto conn) noexcept {
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
if (use_ssl_) {
|
||||
conn->init_ssl(context_);
|
||||
}
|
||||
|
@ -416,7 +417,7 @@ class coro_rpc_server_base {
|
|||
std::atomic<uint16_t> port_;
|
||||
std::chrono::steady_clock::duration conn_timeout_duration_;
|
||||
|
||||
#ifdef ENABLE_SSL
|
||||
#ifdef YLT_ENABLE_SSL
|
||||
asio::ssl::context context_{asio::ssl::context::sslv23};
|
||||
bool use_ssl_ = false;
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,10 +18,10 @@
|
|||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "coro_io/io_context_pool.hpp"
|
||||
#include "coro_rpc/coro_rpc/context.hpp"
|
||||
#include "coro_rpc/coro_rpc/protocol/coro_rpc_protocol.hpp"
|
||||
#include "coro_rpc/coro_rpc_server.hpp"
|
||||
#include "ylt/coro_io/io_context_pool.hpp"
|
||||
#include "ylt/coro_rpc/coro_rpc_server.hpp"
|
||||
#include "ylt/coro_rpc/impl/context.hpp"
|
||||
#include "ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp"
|
||||
|
||||
namespace coro_rpc {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -18,10 +18,10 @@
|
|||
#include <expected>
|
||||
#if __cpp_lib_expected >= 202202L
|
||||
#else
|
||||
#include "util/expected.hpp"
|
||||
#include <ylt/util/expected.hpp>
|
||||
#endif
|
||||
#else
|
||||
#include "util/expected.hpp"
|
||||
#include <ylt/util/expected.hpp>
|
||||
#endif
|
||||
|
||||
namespace coro_rpc {
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,19 +14,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
|
||||
#include <optional>
|
||||
#include <system_error>
|
||||
#include <variant>
|
||||
#include <ylt/easylog.hpp>
|
||||
#include <ylt/struct_pack.hpp>
|
||||
|
||||
#include "../expected.hpp"
|
||||
#include "asio/buffer.hpp"
|
||||
#include "async_simple/coro/Lazy.h"
|
||||
#include "coro_io/coro_io.hpp"
|
||||
#include "coro_rpc/coro_rpc/context.hpp"
|
||||
#include "coro_rpc/coro_rpc/router.hpp"
|
||||
#include "easylog/easylog.h"
|
||||
#include "struct_pack/struct_pack.hpp"
|
||||
#include "struct_pack_protocol.hpp"
|
||||
#include "ylt/coro_io/coro_io.hpp"
|
||||
#include "ylt/coro_rpc/impl/context.hpp"
|
||||
#include "ylt/coro_rpc/impl/expected.hpp"
|
||||
#include "ylt/coro_rpc/impl/router.hpp"
|
||||
|
||||
namespace coro_rpc {
|
||||
namespace protocol {
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <struct_pack/struct_pack.hpp>
|
||||
#include <ylt/struct_pack.hpp>
|
||||
namespace coro_rpc::protocol {
|
||||
|
||||
struct struct_pack_protocol {
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -15,7 +15,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <async_simple/coro/Lazy.h>
|
||||
#include <util/type_traits.h>
|
||||
#include <ylt/util/function_name.h>
|
||||
#include <ylt/util/type_traits.h>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
@ -24,11 +25,10 @@
|
|||
#include <unordered_map>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
#include <ylt/easylog.hpp>
|
||||
#include <ylt/struct_pack/md5_constexpr.hpp>
|
||||
|
||||
#include "easylog/easylog.h"
|
||||
#include "rpc_execute.hpp"
|
||||
#include "struct_pack/struct_pack/md5_constexpr.hpp"
|
||||
#include "util/function_name.h"
|
||||
|
||||
namespace coro_rpc {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "context.hpp"
|
||||
#include "coro_connection.hpp"
|
||||
#include "util/type_traits.h"
|
||||
#include "ylt/util/type_traits.h"
|
||||
|
||||
namespace coro_rpc::internal {
|
||||
// TODO: remove this later
|
|
@ -19,7 +19,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "appender.hpp"
|
||||
#include "easylog/appender.hpp"
|
||||
|
||||
namespace easylog {
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
#include <string_view>
|
||||
|
||||
#include "record.hpp"
|
||||
#include "util/concurrentqueue.h"
|
||||
#include "ylt/util/concurrentqueue.h"
|
||||
|
||||
namespace easylog {
|
||||
constexpr inline std::string_view BOM_STR = "\xEF\xBB\xBF";
|
|
@ -14,7 +14,6 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <util/type_traits.h>
|
||||
|
||||
#include <charconv>
|
||||
#include <chrono>
|
||||
|
@ -29,10 +28,11 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <util/meta_string.hpp>
|
||||
#include <utility>
|
||||
|
||||
#include "util/dragonbox_to_chars.h"
|
||||
#include "ylt/util/dragonbox_to_chars.h"
|
||||
#include "ylt/util/meta_string.hpp"
|
||||
#include "ylt/util/type_traits.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifndef _WINDOWS_
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <system_error>
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -20,7 +20,6 @@
|
|||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
// #include <compare>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -35,13 +35,12 @@
|
|||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "struct_pack/struct_pack.hpp"
|
||||
#include "struct_pack/struct_pack/error_code.hpp"
|
||||
#include "struct_pack/struct_pack/md5_constexpr.hpp"
|
||||
#include "struct_pack/struct_pack/reflection.hpp"
|
||||
#include "struct_pack/struct_pack/trivial_view.hpp"
|
||||
#include "struct_pack/struct_pack/tuple.hpp"
|
||||
#include "struct_pack/struct_pack/varint.hpp"
|
||||
#include "error_code.hpp"
|
||||
#include "md5_constexpr.hpp"
|
||||
#include "reflection.hpp"
|
||||
#include "trivial_view.hpp"
|
||||
#include "tuple.hpp"
|
||||
#include "varint.hpp"
|
||||
|
||||
static_assert(std::endian::native == std::endian::little,
|
||||
"only support little endian now");
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Alibaba Group Holding Limited;
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
|
@ -4,7 +4,7 @@
|
|||
#include <system_error>
|
||||
#include <type_traits>
|
||||
|
||||
#include "struct_pack/struct_pack/reflection.hpp"
|
||||
#include "reflection.hpp"
|
||||
namespace struct_pack {
|
||||
|
||||
namespace detail {
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
|
@ -1,3 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
@ -5,7 +20,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "struct_pb/struct_pb.hpp"
|
||||
#include "ylt/struct_pb.hpp"
|
||||
|
||||
namespace struct_pb {
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <iguana/xml_reader.hpp>
|
||||
|
||||
namespace struct_xml {
|
||||
|
||||
template <int Flags = 0, typename T>
|
||||
inline bool from_xml(T &&t, char *buf) {
|
||||
return iguana::from_xml<Flags>(std::forward<T>(t), buf);
|
||||
}
|
||||
|
||||
template <int Flags = 0, typename T>
|
||||
inline bool from_xml(T &&t, const std::string &str) {
|
||||
return from_xml<Flags>(std::forward<T>(t), str.data());
|
||||
}
|
||||
|
||||
template <int Flags = 0, typename T>
|
||||
inline bool from_xml(T &&t, std::string_view str) {
|
||||
return from_xml<Flags>(std::forward<T>(t), str.data());
|
||||
}
|
||||
|
||||
inline std::string get_last_read_err() { return iguana::get_last_read_err(); }
|
||||
|
||||
using any_t = iguana::any_t;
|
||||
} // namespace struct_xml
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <iguana/xml_writer.hpp>
|
||||
|
||||
namespace struct_xml {
|
||||
template <typename Stream, typename T>
|
||||
inline void to_xml(T &&t, Stream &s) {
|
||||
iguana::to_xml(std::forward<T>(t), s);
|
||||
}
|
||||
|
||||
template <int Flags = 0, typename Stream, typename T>
|
||||
inline bool to_xml_pretty(T &&t, Stream &s) {
|
||||
return iguana::to_xml_pretty<Flags>(std::forward<T>(t), s);
|
||||
}
|
||||
} // namespace struct_xml
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <iguana/yaml_reader.hpp>
|
||||
|
||||
namespace struct_yaml {
|
||||
|
||||
template <typename T, iguana::string_t View>
|
||||
inline void from_yaml(T &value, const View &view) {
|
||||
iguana::from_yaml(value, view);
|
||||
}
|
||||
|
||||
template <typename T, iguana::string_t View>
|
||||
inline void from_yaml(T &value, const View &view, std::error_code &ec) {
|
||||
iguana::from_yaml(value, view, ec);
|
||||
}
|
||||
} // namespace struct_yaml
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Alibaba Group Holding Limited;
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
#include <iguana/yaml_writer.hpp>
|
||||
|
||||
namespace struct_yaml {
|
||||
template <typename Stream, typename T>
|
||||
inline void to_yaml(T &&t, Stream &s, size_t min_spaces = 0) {
|
||||
iguana::to_yaml(std::forward<T>(t), s, min_spaces);
|
||||
}
|
||||
} // namespace struct_yaml
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue