VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::DatabaseWriter Class Referencefinal

Concrete SQLite-backed bag file recorder with transactional write caching. More...

#include <database_writer.h>

Inheritance diagram for vlink::DatabaseWriter:
Collaboration diagram for vlink::DatabaseWriter:

Public Member Functions

 DatabaseWriter (const std::string &path, const Config &config={})
 Constructs a DatabaseWriter for the given path.
 ~DatabaseWriter () override
 Destructor – commits remaining cached writes and closes the SQLite database.
void register_split_callback (SplitCallback &&callback, bool before) override
 Registers a callback invoked when a file split occurs.
void register_schema_callback (SchemaCallback &&callback) override
 Registers a callback that resolves serialisation type strings to SchemaData.
bool push_schema (const SchemaData &schema_data, bool immediate=false) override
 Embeds a SchemaData into the SQLite bag for offline introspection.
int64_t push (const std::string &url, const std::string &ser_type, SchemaType schema_type, ActionType action_type, const Bytes &data, int64_t *microseconds_timestamp=nullptr, bool immediate=false) override
 Records one message to the SQLite bag file.
bool is_dumping () const override
 Returns true if the writer is actively recording to disk.
bool is_split_mode () const override
 Returns true if split-file mode is active.
int get_split_index () const override
 Returns the zero-based index of the current split file.
void set_url_loss (const std::string &url, double loss) override
 Sets the expected message loss ratio for a given URL.

Protected Member Functions

size_t get_max_task_count () const override
 Returns the maximum queue depth.
void on_begin () override
 Called from the loop thread just before the first task is processed.
void on_end () override
 Called from the loop thread just after the last task has been processed.

Additional Inherited Members

 Compression algorithm applied to each recorded payload. More...
 Queue implementation type. More...
 Idle strategy controlling CPU and latency trade-offs. More...
 Pre-defined task priority levels for kPriorityType loops. More...

Detailed Description

Concrete SQLite-backed bag file recorder with transactional write caching.

All virtual methods from BagWriter are implemented. Prefer using BagWriter::create() for format-agnostic construction.

Constructor & Destructor Documentation

◆ DatabaseWriter()

vlink::DatabaseWriter::DatabaseWriter ( const std::string & path,
const Config & config = {} )
explicit

Constructs a DatabaseWriter for the given path.

Parameters
pathPath to the output .vdb file. Created if it does not exist.
configRecording configuration.
Here is the caller graph for this function:

◆ ~DatabaseWriter()

vlink::DatabaseWriter::~DatabaseWriter ( )
override

Destructor – commits remaining cached writes and closes the SQLite database.

Member Function Documentation

◆ get_max_task_count()

size_t vlink::DatabaseWriter::get_max_task_count ( ) const
overrideprotectedvirtual

Returns the maximum queue depth.

Returns
kMaxTaskSize (10000) by default.

Reimplemented from vlink::MessageLoop.

◆ get_split_index()

int vlink::DatabaseWriter::get_split_index ( ) const
nodiscardoverridevirtual

Returns the zero-based index of the current split file.

Implements vlink::BagWriter.

◆ is_dumping()

bool vlink::DatabaseWriter::is_dumping ( ) const
nodiscardoverridevirtual

Returns true if the writer is actively recording to disk.

Implements vlink::BagWriter.

◆ is_split_mode()

bool vlink::DatabaseWriter::is_split_mode ( ) const
nodiscardoverridevirtual

Returns true if split-file mode is active.

Implements vlink::BagWriter.

◆ on_begin()

void vlink::DatabaseWriter::on_begin ( )
overrideprotectedvirtual

Called from the loop thread just before the first task is processed.

Override in subclasses to perform per-thread initialisation.

Reimplemented from vlink::MessageLoop.

◆ on_end()

void vlink::DatabaseWriter::on_end ( )
overrideprotectedvirtual

Called from the loop thread just after the last task has been processed.

Override in subclasses to perform per-thread cleanup.

Reimplemented from vlink::MessageLoop.

Here is the call graph for this function:

◆ push()

int64_t vlink::DatabaseWriter::push ( const std::string & url,
const std::string & ser_type,
SchemaType schema_type,
ActionType action_type,
const Bytes & data,
int64_t * microseconds_timestamp = nullptr,
bool immediate = false )
overridevirtual

Records one message to the SQLite bag file.

Parameters
urlVLink URL of the topic.
ser_typeSerialisation type string.
schema_typeCoarse schema family for the payload.
action_typeAction type (kPublish, kRequest, etc.).
dataSerialized payload bytes.
microseconds_timestampOptional custom timestamp in microseconds. nullptr means use the current system time.
immediateIf true, writes synchronously bypassing the queue.
Returns
Sequence number of the recorded message, or a negative value on error.

Implements vlink::BagWriter.

◆ push_schema()

bool vlink::DatabaseWriter::push_schema ( const SchemaData & schema_data,
bool immediate = false )
overridevirtual

Embeds a SchemaData into the SQLite bag for offline introspection.

Parameters
schema_dataSchema descriptor to store.
immediateIf true, merges synchronously; otherwise enqueues.
Returns
false only when the immediate merge fails.

Implements vlink::BagWriter.

◆ register_schema_callback()

void vlink::DatabaseWriter::register_schema_callback ( SchemaCallback && callback)
overridevirtual

Registers a callback that resolves serialisation type strings to SchemaData.

Parameters
callbackFunction mapping (ser_type, schema_type) to SchemaData.

Implements vlink::BagWriter.

◆ register_split_callback()

void vlink::DatabaseWriter::register_split_callback ( SplitCallback && callback,
bool before )
overridevirtual

Registers a callback invoked when a file split occurs.

Parameters
callbackCalled with (split_index, new_filename) on each split.
beforeIf true, fires before the new file is opened; otherwise after.

Implements vlink::BagWriter.

◆ set_url_loss()

void vlink::DatabaseWriter::set_url_loss ( const std::string & url,
double loss )
overridevirtual

Sets the expected message loss ratio for a given URL.

Parameters
urlTopic URL.
lossLoss ratio in the range [0.0, 1.0].

Implements vlink::BagWriter.


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