1#ifndef joedb_Robust_Connection_declared
2#define joedb_Robust_Connection_declared
17 using clock = std::chrono::steady_clock;
18 using time_point = std::chrono::time_point<clock>;
23 mutable std::unique_ptr<Channel> channel;
28 static constexpr auto period = std::chrono::seconds(5);
29 mutable time_point last_connection_time = clock::now() - period;
31 void log_exception(
const std::exception *e)
const;
36 void reconnect(
const std::exception *e)
const;
50 catch (std::exception &e)
65 size_t pread(
char *data,
size_t size, int64_t offset)
const;
78 std::chrono::milliseconds wait
84 int64_t from_checkpoint,
85 int64_t until_checkpoint,
Used by Robust_Connection to reconnect after an error.
joedb::Robust_Connection does not try to reconnect when thrown
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.