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

Tracks the upload position for telemetry log files. More...

#include <upload_position_tracker.hpp>

Collaboration diagram for upload_position_tracker:
Collaboration graph

Public Member Functions

 upload_position_tracker (std::filesystem::path log_file_path)
 Constructs a tracker for the specified log file.
 
std::uint64_t get_position () const
 Gets the current upload position.
 
void set_position (std::uint64_t position)
 Updates the upload position after a successful upload.
 
const std::filesystem::path & marker_file_path () const
 Gets the path to the marker file.
 
void reset ()
 Resets the tracker to position 0 and deletes the marker file.
 

Detailed Description

Tracks the upload position for telemetry log files.

This class maintains state about which log records have been successfully uploaded to the server. It uses a companion marker file (.uploaded) stored alongside the log file to persist the position across restarts.

The marker file contains a single 64-bit integer representing the byte offset in the log file up to which records have been successfully uploaded. When reconnecting after a disconnect, this position is used to resume uploading from where we left off.

Thread-safe: all public methods are protected by a mutex.

Constructor & Destructor Documentation

◆ upload_position_tracker()

upload_position_tracker ( std::filesystem::path  log_file_path)
explicit

Constructs a tracker for the specified log file.

Parameters
log_file_pathPath to the log file being tracked.

The marker file will be created at log_file_path with ".uploaded" extension added (e.g., "telemetry.jsonl" -> "telemetry.jsonl.uploaded").

Member Function Documentation

◆ get_position()

std::uint64_t get_position ( ) const

Gets the current upload position.

Returns
The byte offset in the log file up to which records have been successfully uploaded. Returns 0 if no records have been uploaded.
Here is the caller graph for this function:

◆ set_position()

void set_position ( std::uint64_t  position)

Updates the upload position after a successful upload.

This atomically updates both the in-memory position and the marker file. The marker file is synced to disk to ensure durability.

Parameters
positionThe new byte offset representing the uploaded position.

◆ marker_file_path()

const std::filesystem::path & marker_file_path ( ) const

Gets the path to the marker file.

Returns
Path to the .uploaded marker file.

◆ reset()

void reset ( )

Resets the tracker to position 0 and deletes the marker file.

Use this when starting a new log file or when the log file has been truncated/rotated.