5 void Robust_Connection::log_exception(
const std::exception *e)
const
8 logger.log(
"Robust_Connection: exception: " + std::string(e->what()));
17 std::this_thread::sleep_until(last_connection_time + period);
18 last_connection_time = clock::now();
24 channel = connector.new_channel();
25 connection = std::make_unique<Server_Connection>
29 connector.get_keep_alive_interval()
31 if (handshake_journal)
32 connection->handshake(*handshake_journal, handshake_content_check);
39 catch (std::exception &reconnect_exception)
41 log_exception(&reconnect_exception);
62 return connection->handshake(client_journal, content_check);
65 handshake_journal = &client_journal;
66 handshake_content_check = content_check;
81 connection->check_matching_content(client_journal, content_check, from, until);
90 std::chrono::milliseconds wait
95 return connection->pull(lock_action, data_transfer, client_journal, wait);
102 int64_t from_checkpoint,
103 int64_t until_checkpoint,
130 catch (
const std::exception &e)
132 logger.log(
"Robust_Connection::unlock() error: " + std::string(e.what()));
joedb::Robust_Connection does not try to reconnect when thrown
void reconnect(const std::exception *e) const
void check_matching_content(const Readonly_Journal &client_journal, Content_Check content_check, int64_t from, int64_t until) override
Compare content of file and connection. Throw if mismatch.
int64_t pull(Lock_Action lock_action, Data_Transfer data_transfer, Writable_Journal &client_journal, std::chrono::milliseconds wait) override
Pull from the connection.
std::unique_ptr< Server_Connection > connection
size_t pread(char *data, size_t size, int64_t offset) const
int64_t handshake(const Readonly_Journal &client_journal, Content_Check content_check) override
Called during Client construction.
auto try_until_success(const F &f) const
int64_t push(const Readonly_Journal &client_journal, int64_t from_checkpoint, int64_t until_checkpoint, Unlock_Action unlock_action) override
Push new data to the connection.
void unlock() override
Unlock the connection.