Joedb 10.3.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
rpc_server.cpp
Go to the documentation of this file.
3#include "joedb/rpc/Server.h"
4
8
9#include <iostream>
10
11namespace joedb
12{
13 static int rpc_server(Arguments &arguments)
14 {
15 Parsed_Logger logger(arguments);
16
17 const std::string_view endpoint_option = arguments.get_string_option
18 (
19 "socket",
20 "endpoint_path",
21 ""
22 );
23
24 const std::string_view file = arguments.get_next("<file.joedb>");
25
26 if (arguments.missing())
27 {
28 arguments.print_help(std::cerr);
29 return 1;
30 }
31
32 const std::string endpoint_path = endpoint_option.empty()
33 ? std::string(file) + ".rpc.sock"
34 : std::string(endpoint_option);
35
36 tutorial::File_Client client(file.data());
37 tutorial::rpc::Service service(client);
38
39 tutorial::rpc::Procedures procedures(service);
40
41 rpc::Server server
42 (
43 logger.get(),
44 logger.get_log_level(),
45 1,
46 std::string(endpoint_path),
48 procedures.procedures
49 );
50
51 server.join();
52
53 return 0;
54 }
55}
56
57int main(int argc, char **argv)
58{
59 return joedb::main_wrapper(joedb::rpc_server, argc, argv);
60}
Shortcut to directly build a Client from a file name.
Definition File_Client.h:22
A collection of procedures to be used by joedb::rpc::Server.
Definition Procedures.h:23
A collection of procedures that will be executed in the rpc server.
Definition Service.h:17
int main()
int main_wrapper(int(*main)(Arguments &), int argc, char **argv)
Process command-line arguments and catch exceptions from main.
const auto & get_signatures()
Get the list of procedure signatures. Used by RPC client and server.
Definition Signatures.h:23