ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
hybrid_log_exporter Class Referencefinal

Hybrid exporter that writes to file and optionally streams to server. More...

#include <hybrid_log_exporter.hpp>

Inheritance diagram for hybrid_log_exporter:
Inheritance graph
Collaboration diagram for hybrid_log_exporter:
Collaboration graph

Public Member Functions

 hybrid_log_exporter (const std::filesystem::path &file_path, telemetry_options options, send_records_callback send_callback=nullptr)
 Constructs a hybrid log exporter.
 
 hybrid_log_exporter (const hybrid_log_exporter &)=delete
 
hybrid_log_exporteroperator= (const hybrid_log_exporter &)=delete
 
void export_record (domain::log_record record) override
 Exports a log record.
 
void flush () override
 Flushes pending records.
 
void shutdown () override
 Shuts down the exporter.
 
void set_connected (bool connected)
 Updates the connection status.
 
std::uint64_t upload_position () const
 Returns the current upload position.
 

Detailed Description

Hybrid exporter that writes to file and optionally streams to server.

This exporter implements a dual-export strategy:

  1. All records are always written to a local JSON Lines file
  2. When streaming is enabled and the connection is available, records are batched and sent to the server

The exporter maintains durability through:

Thread-safety: All public methods are thread-safe.

Constructor & Destructor Documentation

◆ hybrid_log_exporter()

hybrid_log_exporter ( const std::filesystem::path &  file_path,
telemetry_options  options,
send_records_callback  send_callback = nullptr 
)

Constructs a hybrid log exporter.

Parameters
file_pathPath to the JSON Lines output file.
optionsTelemetry configuration options.
send_callbackCallback for sending records to the server. May be nullptr if streaming is disabled.

Member Function Documentation

◆ export_record()

void export_record ( domain::log_record  record)
overridevirtual

Exports a log record.

The record is immediately written to the file. If streaming is enabled, it is also added to the pending batch. The batch is sent when it reaches batch_size or when flush_interval has elapsed.

Parameters
recordThe log record to export.

Implements log_exporter.

◆ flush()

void flush ( )
overridevirtual

Flushes pending records.

Forces immediate file flush and sends any pending batch to the server (if streaming is enabled and connected).

Implements log_exporter.

Here is the caller graph for this function:

◆ shutdown()

void shutdown ( )
overridevirtual

Shuts down the exporter.

Flushes pending records and stops the background flush thread.

Implements log_exporter.

◆ set_connected()

void set_connected ( bool  connected)

Updates the connection status.

When connection becomes available after being disconnected, this triggers upload of any records that accumulated during the disconnect.

Parameters
connectedtrue if connection is available.