cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
tcp_backend.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2023 MusicScience37 (Kenta Kabashima)
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 */
21
22#include <memory>
23#include <utility>
24
31
33
34TCPBackend::TCPBackend(const std::shared_ptr<executors::IExecutor>& executor,
35 const config::MessageParserConfig& message_parser_config,
36 std::shared_ptr<logging::Logger> logger)
38 message_parser_config_(message_parser_config),
39 logger_(std::move(logger)) {}
40
41std::string_view TCPBackend::scheme() const noexcept {
43}
44
45std::shared_ptr<IAcceptorFactory> TCPBackend::create_acceptor_factory() {
46 return std::make_shared<TCPAcceptorFactory>(
48}
49
50std::shared_ptr<IConnector> TCPBackend::create_connector() {
51 return std::make_shared<TCPConnector>(
53}
54
55TCPBackend::~TCPBackend() noexcept = default;
56
57std::shared_ptr<executors::IExecutor> TCPBackend::executor() const {
58 auto locked = executor_.lock();
59 if (!locked) {
61 StatusCode::PRECONDITION_NOT_MET, "Executor has been deleted.");
62 }
63 return locked;
64}
65
66} // namespace msgpack_rpc::transport::tcp
Class of exceptions in cpp-msgpack-rpc library.
Class of configuration of parsers of messages.
TCPBackend(const std::shared_ptr< executors::IExecutor > &executor, const config::MessageParserConfig &message_parser_config, std::shared_ptr< logging::Logger > logger)
Constructor.
config::MessageParserConfig message_parser_config_
Configuration of parsers of messages.
Definition tcp_backend.h:80
std::string_view scheme() const noexcept override
Get the scheme.
std::shared_ptr< logging::Logger > logger_
Logger.
Definition tcp_backend.h:83
std::shared_ptr< executors::IExecutor > executor() const
Get the executor.
std::shared_ptr< IAcceptorFactory > create_acceptor_factory() override
Create a factory to create acceptors.
std::weak_ptr< executors::IExecutor > executor_
Executor.
Definition tcp_backend.h:77
~TCPBackend() noexcept override
Destructor.
std::shared_ptr< IConnector > create_connector() override
Create a connector to connect to endpoints of acceptors.
Definition of MessageParserConfig class.
Definition of MsgpackRPCException class.
constexpr std::string_view TCP_SCHEME
Scheme of TCP.
Definition schemes.h:27
Namespace of executors to process asynchronous tasks.
Namespace of transport of messages via TCP.
STL namespace.
Definition of constants of schemes.
Definition of StatusCode enumeration.
Definition of TCPAcceptorFactory class.
Definition of TCPBackend class.
Definition of TCPConnector class.