yaLanTingLibs
载入中...
搜索中...
未找到
coro_rpc_doc.hpp
1/*
2 * Copyright (c) 2023, Alibaba Group Holding Limited;
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17#include <ylt/coro_rpc/coro_rpc_server.hpp>
27namespace coro_rpc {
28
48 public:
60 coro_rpc_server(size_t thread_num, unsigned short port,
61 size_t conn_timeout_seconds = 0);
68 async_simple::coro::Lazy<coro_rpc::err_code> async_start() noexcept;
74 coro_rpc::err_code start();
78 void stop();
79
84 uint16_t port();
85
90 auto &get_executor();
91
125 template <auto first, auto... func>
127
137 template <auto first, auto... func>
138 void register_handler(util::class_type_t<decltype(first)> *self);
139};
140
161struct rpc_error {
162 coro_rpc::err_code code;
163 std::string msg;
164};
165
194 public:
199
204 coro_rpc_client(asio::io_context &io_context);
218 async_simple::coro::Lazy<coro_rpc::err_code> connect(
219 const std::string &host, const std::string &port,
220 std::chrono::steady_clock::duration timeout_duration =
221 std::chrono::seconds(5));
222
231 template <auto func, typename... Args>
232 async_simple::coro::Lazy<
233 rpc_result<util::function_return_type_t<decltype(func)>>>
234 call(Args &&...args);
235
244 template <auto func, typename... Args>
245 async_simple::coro::Lazy<
246 rpc_result<util::function_return_type_t<decltype(func)>>>
247 call_for(const auto &duration, Args &&...args);
248
254};
255} // namespace coro_rpc
Definition coro_rpc_doc.hpp:193
async_simple::coro::Lazy< rpc_result< util::function_return_type_t< decltype(func)> > > call_for(const auto &duration, Args &&...args)
async_simple::coro::Lazy< coro_rpc::err_code > connect(const std::string &host, const std::string &port, std::chrono::steady_clock::duration timeout_duration=std::chrono::seconds(5))
coro_rpc_client(asio::io_context &io_context)
async_simple::coro::Lazy< rpc_result< util::function_return_type_t< decltype(func)> > > call(Args &&...args)
Definition coro_rpc_doc.hpp:47
coro_rpc::err_code start()
coro_rpc_server(size_t thread_num, unsigned short port, size_t conn_timeout_seconds=0)
async_simple::coro::Lazy< coro_rpc::err_code > async_start() noexcept
Definition coro_rpc_doc.hpp:161