|
ORE Studio 0.0.4
|
Tracks the upload position for telemetry log files. More...
#include <upload_position_tracker.hpp>

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. | |
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.
|
explicit |
Constructs a tracker for the specified log file.
| log_file_path | Path 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").
| 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.
This atomically updates both the in-memory position and the marker file. The marker file is synced to disk to ensure durability.
| position | The new byte offset representing the uploaded position. |
| 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.
Use this when starting a new log file or when the log file has been truncated/rotated.