cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
tcp_backend.h
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 */
20#pragma once
21
22#include <memory>
23#include <string_view>
24
31
33
37class TCPBackend final : public IBackend {
38public:
46 TCPBackend(const std::shared_ptr<executors::IExecutor>& executor,
47 const config::MessageParserConfig& message_parser_config,
48 std::shared_ptr<logging::Logger> logger);
49
51 [[nodiscard]] std::string_view scheme() const noexcept override;
52
54 [[nodiscard]] std::shared_ptr<IAcceptorFactory> create_acceptor_factory()
55 override;
56
58 [[nodiscard]] std::shared_ptr<IConnector> create_connector() override;
59
60 TCPBackend(const TCPBackend&) = delete;
61 TCPBackend(TCPBackend&&) = delete;
62 TCPBackend& operator=(const TCPBackend&) = delete;
63 TCPBackend& operator=(TCPBackend&&) = delete;
64
66 ~TCPBackend() noexcept override;
67
68private:
74 [[nodiscard]] std::shared_ptr<executors::IExecutor> executor() const;
75
77 std::weak_ptr<executors::IExecutor> executor_;
78
80 config::MessageParserConfig message_parser_config_;
81
83 std::shared_ptr<logging::Logger> logger_;
84};
85
86} // namespace msgpack_rpc::transport::tcp
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 IAcceptorFactory class.
Definition of IBackend class.
Definition of IConnector class.
Definition of IExecutor class.
Definition of Logger class.
Definition of MessageParserConfig class.
Namespace of configurations.
Namespace of executors to process asynchronous tasks.
Namespace of logging.
Definition i_log_sink.h:27
Namespace of transport of messages via TCP.
STL namespace.