using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Telemetry.Reporting;
namespace Tango.Telemetry
{
///
/// Defines the interface for a telemetry publisher responsible for managing sources, destinations,
/// storage, and the overall publishing lifecycle.
///
public interface ITelemetryPublisher : IDisposable
{
///
/// Occurs before a telemetry package is published to a destination.
///
event EventHandler PublishingPackage;
///
/// Occurs when a telemetry package has been successfully published to a destination.
///
event EventHandler PackagePublished;
///
/// Occurs when a telemetry package fails to publish to a destination.
///
event EventHandler PublishPackageFailed;
///
/// Occurs when a telemetry publish operation has completed and a publish result is available,
/// indicating the success or failure status for each destination.
///
event EventHandler PublishResultAvailable;
///
/// Gets the storage manager used for telemetry persistence and checkpoint handling.
///
ITelemetryStorageManager StorageManager { get; }
///
/// Gets the telemetry queue manager responsible for internal queuing and retry logic.
///
ITelemetryQueueManager QueueManager { get; }
///
/// Gets the client used for remote checkpoint recovery.
///
ITelemetryCheckpointsRecoveryClient CheckpointsRecoveryClient { get; }
///
/// Gets the registered telemetry sources.
///
ReadOnlyCollection Sources { get; }
///
/// Registers a telemetry source with the publisher.
///
/// The telemetry source to register.
void RegisterSource(ITelemetrySource source);
///
/// Gets the registered telemetry destinations.
///
ReadOnlyCollection Destinations { get; }
///
/// Registers a telemetry destination with the publisher.
///
/// The telemetry destination to register.
void RegisterDestination(ITelemetryDestination destination);
///
/// Gets a value indicating whether the publisher is currently running.
///
bool IsStarted { get; }
///
/// Starts the telemetry publishing pipeline, including sources and destinations.
///
/// A task representing the asynchronous start operation.
Task Start();
///
/// Stops the telemetry publishing pipeline and releases all resources.
///
/// A task representing the asynchronous stop operation.
Task Stop();
///
/// Flushes up to the specified number of pending telemetries from local storage,
/// attempting to publish them immediately. This can be used to force a retry of previously failed or postponed telemetry packages.
///
/// The maximum number of pending telemetry packages to flush.
/// A task that represents the asynchronous flush operation, returning a list of publish results for the flushed packages.
Task> FlushPendingTelemetries(int maxCount);
///
/// Generates a detailed telemetry report summarizing the current state of the telemetry system.
/// The report includes statistics on published and pending telemetry, as well as per-source and per-destination results.
///
Task GetTelemetryReport();
}
}