cpp-msgpack-rpc 0.2.0
An RPC library implementing MessagePack RPC.
Loading...
Searching...
No Matches
i_server_builder_impl.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
27#include "msgpack_rpc/impl/msgpack_rpc_export.h"
32
34
38class IServerBuilderImpl {
39public:
45 virtual void register_protocol(
46 std::shared_ptr<transport::IBackend> backend) = 0;
47
53 virtual void listen_to(addresses::URI uri) = 0;
54
60 virtual void add_method(std::unique_ptr<methods::IMethod> method) = 0;
61
67 [[nodiscard]] virtual std::unique_ptr<IServerImpl> build() = 0;
68
74 [[nodiscard]] virtual std::shared_ptr<logging::Logger> logger() = 0;
75
76 IServerBuilderImpl(const IServerBuilderImpl&) = delete;
77 IServerBuilderImpl(IServerBuilderImpl&&) = delete;
78 IServerBuilderImpl& operator=(const IServerBuilderImpl&) = delete;
79 IServerBuilderImpl& operator=(IServerBuilderImpl&&) = delete;
80
82 virtual ~IServerBuilderImpl() noexcept = default;
83
84protected:
86 IServerBuilderImpl() noexcept = default;
87};
88
96[[nodiscard]] MSGPACK_RPC_EXPORT std::unique_ptr<IServerBuilderImpl>
98 std::shared_ptr<executors::IAsyncExecutor> executor,
99 std::shared_ptr<logging::Logger> logger);
100
108[[nodiscard]] MSGPACK_RPC_EXPORT std::unique_ptr<IServerBuilderImpl>
109create_default_builder_impl(const config::ServerConfig& server_config,
110 const std::shared_ptr<logging::Logger>& logger);
111
112} // namespace msgpack_rpc::servers::impl
Class of URIs (Uniform Resource Identifiers) to specify endpoints in this library.
Definition uri.h:38
virtual void register_protocol(std::shared_ptr< transport::IBackend > backend)=0
Register a protocol.
virtual std::unique_ptr< IServerImpl > build()=0
Build a server.
virtual std::shared_ptr< logging::Logger > logger()=0
Get the logger in this builder.
virtual void listen_to(addresses::URI uri)=0
Add a URI to listen to.
virtual void add_method(std::unique_ptr< methods::IMethod > method)=0
Add a method.
IServerBuilderImpl() noexcept=default
Constructor.
virtual ~IServerBuilderImpl() noexcept=default
Destructor.
Definition of IAsyncExecutor class.
Definition of IBackend class.
Definition of IMethod class.
Definition of IServerImpl class.
Definition of Logger class.
Namespace of configurations.
Namespace of executors to process asynchronous tasks.
Namespace of logging.
Definition i_log_sink.h:27
Namespace of internal implementation.
std::unique_ptr< IServerBuilderImpl > create_empty_server_builder_impl(std::shared_ptr< executors::IAsyncExecutor > executor, std::shared_ptr< logging::Logger > logger)
Create an empty IServerBuilderImpl object.
std::unique_ptr< IServerBuilderImpl > create_default_builder_impl(const config::ServerConfig &server_config, const std::shared_ptr< logging::Logger > &logger)
Create an IServerBuilderImpl object with default protocols.
STL namespace.
Definition of ServerConfig class.
Definition of URI class.