61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using StellaOps.Plugin.Abstractions.Execution;
|
|
using StellaOps.Plugin.Abstractions.Health;
|
|
|
|
namespace StellaOps.Plugin.Host.Health;
|
|
|
|
/// <summary>
|
|
/// Monitors the health of loaded plugins.
|
|
/// </summary>
|
|
public interface IPluginHealthMonitor : IAsyncDisposable
|
|
{
|
|
/// <summary>
|
|
/// Start the health monitoring loop.
|
|
/// </summary>
|
|
/// <param name="ct">Cancellation token.</param>
|
|
Task StartAsync(CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// Stop the health monitoring loop.
|
|
/// </summary>
|
|
/// <param name="ct">Cancellation token.</param>
|
|
Task StopAsync(CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// Register a plugin for health monitoring.
|
|
/// </summary>
|
|
/// <param name="plugin">The loaded plugin.</param>
|
|
void RegisterPlugin(LoadedPlugin plugin);
|
|
|
|
/// <summary>
|
|
/// Unregister a plugin from health monitoring.
|
|
/// </summary>
|
|
/// <param name="pluginId">The plugin ID.</param>
|
|
void UnregisterPlugin(string pluginId);
|
|
|
|
/// <summary>
|
|
/// Perform an immediate health check on a plugin.
|
|
/// </summary>
|
|
/// <param name="pluginId">The plugin ID.</param>
|
|
/// <param name="ct">Cancellation token.</param>
|
|
/// <returns>The health check result.</returns>
|
|
Task<HealthCheckResult> CheckHealthAsync(string pluginId, CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// Get the current health status of a plugin.
|
|
/// </summary>
|
|
/// <param name="pluginId">The plugin ID.</param>
|
|
/// <returns>The health status, or null if not registered.</returns>
|
|
HealthStatus? GetHealthStatus(string pluginId);
|
|
|
|
/// <summary>
|
|
/// Get all plugin health statuses.
|
|
/// </summary>
|
|
/// <returns>Dictionary of plugin ID to health status.</returns>
|
|
IReadOnlyDictionary<string, HealthStatus> GetAllHealthStatuses();
|
|
|
|
/// <summary>
|
|
/// Event raised when a plugin's health status changes.
|
|
/// </summary>
|
|
event EventHandler<PluginHealthChangedEventArgs>? HealthChanged;
|
|
}
|