1#ifndef joedb_Robust_Connection_declared
2#define joedb_Robust_Connection_declared
16 using clock = std::chrono::steady_clock;
17 using time_point = std::chrono::time_point<clock>;
22 mutable std::unique_ptr<Channel> channel;
27 static constexpr auto period = std::chrono::seconds(5);
28 mutable time_point last_connection_time = clock::now() - period;
30 void log_exception(
const std::exception *e)
const;
35 void reconnect(
const std::exception *e)
const;
45 catch (
const std::exception &e)
60 size_t pread(
char *data,
size_t size, int64_t offset)
const;
73 std::chrono::milliseconds wait
79 int64_t from_checkpoint,
80 int64_t until_checkpoint,
Used by Robust_Connection to reconnect after an error.
Server_Connection that automatically reconnects on error
bool is_pullonly() const override
void reconnect(const std::exception *e) const
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.
Robust_Connection(const Connector &connector, std::ostream *log)
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.