class RpcBuilderBase
C++
class RpcBuilderBase
Settings shared by every transport. Start from RpcBuilder, call
with_tcp(), with_http() or with_quic() for transport-specific ones,
and finish with build().
The transport builders are returned by value but share one configuration,
so any of them can call build():
auto rpc = nprpc::RpcBuilder()
.set_log_level(nprpc::LogLevel::warn)
.with_hostname("example.com")
.with_http(8443)
.ssl("cert.pem", "key.pem")
.root_dir("www")
.build();
include/nprpc/nprpc.hpp:716
Methods
Rpc *build()
Starts the runtime with this configuration. There is one per process.
include/nprpc/nprpc.hpp:801
RpcBuilderBase &disable_ssl_client_verification() noexcept
Accepts any certificate on outgoing TLS connections. For testing only.
include/nprpc/nprpc.hpp:755
RpcBuilderBase &enable_ssl_client_self_signed_cert(std::string_view cert_path) noexcept
Trusts the certificate at cert_path for outgoing TLS connections,
e.g. a development server's self-signed one.
include/nprpc/nprpc.hpp:748
RpcBuilderBase &set_log_level(::nprpc::LogLevel level) noexcept
Runtime log verbosity. Default: set at build time
(NPRPC_DEFAULT_LOG_LEVEL).
include/nprpc/nprpc.hpp:726
RpcBuilderBase &shm_channel_sizes(size_t ring_bytes, size_t max_message_bytes) noexcept
How much shared memory each accepted client costs this server.
Two rings of ring_bytes are created per client and both are resident
for the life of the connection, so this is a per-client memory price
paid whether the client is busy or idle. Raise it for a server whose
messages are large — the ring must be able to hold a whole one — and
note that a single oversized call (an image, a document) is usually
better carried in its own segment than paid for on every connection.
Client processes need no matching call: the sizes are written into the ring header at creation and adopted by whoever opens it.
ring_bytes- size of each ring, per direction.
max_message_bytes- largest single message; must be smaller than
ring_bytes, and is clamped with a warning if it is not.
include/nprpc/nprpc.hpp:776
RpcBuilderBase &with_hostname(std::string_view hostname) noexcept
Host name advertised in the URLs of objects activated here, so clients on other machines can reach them.
include/nprpc/nprpc.hpp:737
RpcBuilderHttp with_http(uint16_t port) noexcept
Serves HTTP, WebSocket and (with enable_http3) HTTP/3 and
WebTransport on port: RPC at /rpc, pages, and static files.
include/nprpc/nprpc.hpp:792
RpcBuilderQuic with_quic(uint16_t port) noexcept
Listens for native QUIC clients on port.
include/nprpc/nprpc.hpp:797
RpcBuilderTcp with_tcp(uint16_t port) noexcept
Listens for native TCP clients on port.
include/nprpc/nprpc.hpp:786