using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Tango.Telemetry { /// /// Defines the contract for managing telemetry storage, including pending telemetries and history source checkpoints. /// public interface ITelemetryStorageManager : IDisposable { /// /// Initializes the storage manager with the specified checkpoints recovery client. /// Responsible for loading the database, restoring from backup if necessary, and recovering remote checkpoints. /// /// An implementation of the checkpoint recovery client used for cloud fallback. Task Init(ITelemetryCheckpointsRecoveryClient checkpointsRecoveryClient); /// /// Inserts or updates a pending telemetry record in the local storage. /// /// The pending telemetry to be stored or updated. void UpsertPendingTelemetry(PendingTelemetry pendingTelemetry); /// /// Deletes a pending telemetry record from the local storage. /// /// The pending telemetry to be deleted. void DeletePendingTelemetry(PendingTelemetry pendingTelemetry); /// /// Retrieves a list of pending telemetry records, ordered by time, up to the specified maximum count. /// /// The maximum number of pending telemetries to retrieve. /// A list of pending telemetry objects. List GetPendingTelemetries(int maxCount); /// /// Gets the total number of pending telemetry records currently stored. /// /// The count of pending telemetry records. int GetPendingTelemetriesCount(); /// /// Retrieves the current checkpoint for the specified history source. /// /// The telemetry history source for which to retrieve the checkpoint. /// The stored checkpoint information for the given source. TelemetryHistorySourceCheckPoint GetHistorySourceCheckPoint(ITelemetryHistorySource source); /// /// Retrieves all stored history source checkpoints currently tracked by the storage system. /// Each checkpoint represents the latest processed state of a specific telemetry history source. /// /// A list of entries for all registered history sources. List GetHistorySourcesCheckPoints(); /// /// Sets or updates the checkpoint for the specified history source. /// /// The telemetry history source for which to update the checkpoint. /// The latest timestamp of telemetry data processed for the source. /// The total number of telemetry records processed for the source. void SetHistorySourceCheckPoint(ITelemetryHistorySource source, DateTime time, int totalCount); /// /// Adds the specified telemetry item to the published telemetry cache, /// ensuring it is tracked as already published by the system. /// /// The telemetry instance to register as published. void AddToPublishedTelemetryCache(ITelemetry telemetry); /// /// Checks whether the specified telemetry item is already present in the published telemetry cache. /// /// The telemetry instance to verify. /// True if the telemetry appears to have already been published; otherwise, false. bool IsTelemetryInPublishedCache(ITelemetry telementry); /// /// Removes entries from the published telemetry cache that were marked as published /// before the specified time. Intended to manage memory and storage growth over time, /// especially once historical sources have progressed beyond the given point. /// /// The timestamp indicating the oldest publication time to retain. Entries older than this will be removed. void PerformPublishedTelemetriesCleanUp(DateTime olderThan); } }