Joedb 10.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
joedb::Robust_Connection Class Reference

Server_Connection that automatically reconnects on error More...

#include <joedb/concurrency/Robust_Connection.h>

Inheritance diagram for joedb::Robust_Connection:
Collaboration diagram for joedb::Robust_Connection:

Public Member Functions

 Robust_Connection (const Connector &connector, Logger &logger)
Channel & get_channel ()
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.
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.
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 ping ()
void unlock () override
 Unlock the connection.
bool is_pullonly () const override
Public Member Functions inherited from joedb::Connection
virtual ~Connection ()

Protected Member Functions

void reconnect (const std::exception *e) const
template<typename F>
auto try_until_success (const F &f) const
Protected Member Functions inherited from joedb::Connection
 Connection ()=default

Protected Attributes

std::unique_ptr< Server_Connection > connection

Additional Inherited Members

Static Public Attributes inherited from joedb::Connection
static Connection dummy
 Since this class has no internal state, this global variable can be used instead of creating an instance.
Static Protected Member Functions inherited from joedb::Connection
static void content_mismatch ()
 Called by handshake when the file and the connection do not match.

Detailed Description

Definition at line 13 of file Robust_Connection.h.

Constructor & Destructor Documentation

◆ Robust_Connection()

joedb::Robust_Connection::Robust_Connection ( const Connector & connector,
Logger & logger )
inline

Definition at line 56 of file Robust_Connection.h.

Member Function Documentation

◆ check_matching_content()

void joedb::Robust_Connection::check_matching_content ( const Readonly_Journal & client_journal,
Content_Check content_check,
int64_t from,
int64_t until )
overridevirtual

Reimplemented from joedb::Connection.

Definition at line 71 of file Robust_Connection.cpp.

◆ get_channel()

Channel & joedb::Robust_Connection::get_channel ( )
inline

Definition at line 63 of file Robust_Connection.h.

◆ handshake()

int64_t joedb::Robust_Connection::handshake ( const Readonly_Journal & client_journal,
Content_Check content_check )
overridevirtual
Parameters
client_journalmay be used to check matching content
content_checkindicates how matching content is tested
Returns
connection checkpoint

Reimplemented from joedb::Connection.

Reimplemented in joedb::Server_File.

Definition at line 54 of file Robust_Connection.cpp.

◆ is_pullonly()

bool joedb::Robust_Connection::is_pullonly ( ) const
inlineoverridevirtual

Reimplemented from joedb::Connection.

Definition at line 100 of file Robust_Connection.h.

◆ ping()

void joedb::Robust_Connection::ping ( )

Definition at line 119 of file Robust_Connection.cpp.

◆ pread()

size_t joedb::Robust_Connection::pread ( char * data,
size_t size,
int64_t offset ) const

Definition at line 46 of file Robust_Connection.cpp.

◆ pull()

int64_t joedb::Robust_Connection::pull ( Lock_Action lock_action,
Data_Transfer data_transfer,
Writable_Journal & client_journal,
std::chrono::milliseconds wait )
overridevirtual
Parameters
lock_actionwhether the connection should be locked before pulling
data_transferwhether data should be transferred
client_journaljournal to pull into
waitduration during which the connection may wait for new data if the pull would otherwise be empty
Returns
connection checkpoint

Reimplemented from joedb::Connection.

Reimplemented in joedb::Server_File.

Definition at line 85 of file Robust_Connection.cpp.

◆ push()

int64_t joedb::Robust_Connection::push ( const Readonly_Journal & client_journal,
int64_t from,
int64_t until,
Unlock_Action unlock_action )
overridevirtual
Returns
connection checkpoint

Reimplemented from joedb::Connection.

Reimplemented in joedb::Server_File.

Definition at line 99 of file Robust_Connection.cpp.

◆ reconnect()

void joedb::Robust_Connection::reconnect ( const std::exception * e) const
protected

Definition at line 11 of file Robust_Connection.cpp.

◆ try_until_success()

template<typename F>
auto joedb::Robust_Connection::try_until_success ( const F & f) const
inlineprotected

Definition at line 36 of file Robust_Connection.h.

◆ unlock()

void joedb::Robust_Connection::unlock ( )
overridevirtual

Reimplemented from joedb::Connection.

Definition at line 124 of file Robust_Connection.cpp.

Member Data Documentation

◆ connection

std::unique_ptr<Server_Connection> joedb::Robust_Connection::connection
mutableprotected

Definition at line 32 of file Robust_Connection.h.


The documentation for this class was generated from the following files: