Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
keepalive_test.cpp
Go to the documentation of this file.
6
7#include <iostream>
8
9namespace joedb
10{
11 /// test how long we can wait without losing connection
12 static int keepalive_test(int argc, char **argv)
13 {
14 if (argc < 4)
15 {
16 std::cerr << "usage: " << argv[0] << " <user> <host> <endpoint_path>\n";
17 return 1;
18 }
19
20 std::chrono::seconds wait(1);
21 std::chrono::seconds increment(1);
22
23 Memory_File file;
24 Writable_Journal journal(file);
25
26 while (true)
27 {
28 ssh::Session session(argv[1], argv[2], 22, 0);
29 ssh::Forward_Channel channel(session, argv[3]);
30 Server_Connection connection(channel, &std::cerr);
31 Writable_Client client(journal, connection, Content_Check::none);
32
33 try
34 {
35 channel.set_timeout(wait + increment + std::chrono::seconds(30));
36 client.pull(wait + increment);
37 wait = wait + increment;
38 increment *= 2;
39 }
40 catch (const std::exception &e)
41 {
42 std::cerr << "Caught exception: " << e.what() << '\n';
43 increment = (std::chrono::seconds(3) + increment) / 4;
44 }
45 }
46
47 return 0;
48 }
49}
50
51int main(int argc, char **argv)
52{
53 return joedb::main_exception_catcher(joedb::keepalive_test, argc, argv);
54}
int main()
int main_exception_catcher(int(*main)(int, char **), int argc, char **argv)
Catch exception from main.
Definition Blob.h:7