Joedb 10.2.3
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
rpc_server.cpp
Go to the documentation of this file.
2#include "joedb/rpc/Server.h"
4
8
9#include <iostream>
10
11namespace joedb
12{
13 static int rpc_server(Arguments &arguments)
14 {
15 const std::string_view endpoint_option = arguments.get_string_option
16 (
17 "socket",
18 "endpoint_path",
19 ""
20 );
21
22 const int log_level = arguments.get_option<int>("log_level", "level", 100);
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 Stream_Logger logger(std::cerr);
37
38 tutorial::File_Client client(file.data());
39 tutorial::rpc::Service service(client);
40
41 tutorial::rpc::Procedures procedures(service);
42
43 rpc::Server server
44 (
45 logger,
46 log_level,
47 1,
48 std::string(endpoint_path),
50 procedures.procedures
51 );
52
53 server.join();
54
55 return 0;
56 }
57}
58
59int main(int argc, char **argv)
60{
61 return joedb::main_wrapper(joedb::rpc_server, argc, argv);
62}
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