Joedb 10.4.1
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
rpc_client.cpp
Go to the documentation of this file.
6
7#include <iostream>
8
9namespace joedb
10{
11 static int rpc_client(Arguments &arguments)
12 {
13 const std::string_view endpoint_path = arguments.get_next("<endpoint_path>");
14
15 if (arguments.missing())
16 {
17 arguments.print_help(std::cerr);
18 return 1;
19 }
20
21 Local_Channel channel((std::string(endpoint_path)));
22 tutorial::rpc::Client rpc_client(channel, std::chrono::milliseconds{1000});
23 std::this_thread::sleep_for(std::chrono::seconds{3});
24
25 {
27 city.set_name("Tombouctou");
28 rpc_client.insert_city(city);
29
30 try
31 {
32 rpc_client.insert_city(city);
33 }
34 catch (std::exception &e)
35 {
36 std::cout << "Caught exception: " << e.what() << '\n';
37 }
38
39 rpc_client.delete_city(city);
40 }
41
42 {
44 population.set_city_name(population.new_data(), "Tokyo");
45 population.set_city_name(population.new_data(), "Tombouctou");
46 population.set_city_name(population.new_data(), "Lille");
47 rpc_client.get_population(population);
49 }
50
51 {
53 db.set_name(db.new_city(), "Lille");
54 rpc_client.get_inhabitants(db);
55 tutorial::print_person_table(std::cout, db);
56 }
57
58 return 0;
59 }
60}
61
62int main(int argc, char **argv)
63{
64 return joedb::main_wrapper(joedb::rpc_client, argc, argv);
65}
Shortcut to directly build a Writable_Database with a Memory_File.
void set_name(id_of_city record, std::string_view field_value_of_name)
Specialization of joedb::rpc::Client.
Definition Client.h:22
Shortcut to directly build a Writable_Database with a Memory_File.
void set_name(id_of_city record, std::string_view field_value_of_name)
Shortcut to directly build a Writable_Database with a Memory_File.
void set_city_name(id_of_data record, std::string_view field_value_of_city_name)
int main()
int main_wrapper(int(*main)(Arguments &), int argc, char **argv)
Process command-line arguments and catch exceptions from main.
void print_data_table(std::ostream &out, const Database &db, size_t max_column_width=0, Record_Id start=Record_Id::null, size_t length=0)
Definition print_table.h:42
void print_person_table(std::ostream &out, const Database &db, size_t max_column_width=0, Record_Id start=Record_Id::null, size_t length=0)
Definition print_table.h:42