release orchestrator v1 draft and build fixes
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
namespace StellaOps.Plugin.Abstractions.Lifecycle;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the current state of a plugin in its lifecycle.
|
||||
/// </summary>
|
||||
public enum PluginLifecycleState
|
||||
{
|
||||
/// <summary>
|
||||
/// Plugin has been discovered but not yet loaded.
|
||||
/// This is the initial state after manifest parsing.
|
||||
/// </summary>
|
||||
Discovered = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin assembly is being loaded into the application domain.
|
||||
/// </summary>
|
||||
Loading = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin is being initialized via <see cref="IPlugin.InitializeAsync"/>.
|
||||
/// </summary>
|
||||
Initializing = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin is fully initialized and ready to handle requests.
|
||||
/// This is the normal operating state.
|
||||
/// </summary>
|
||||
Active = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin is functioning but with reduced capability or performance.
|
||||
/// May transition back to Active or to Unhealthy.
|
||||
/// </summary>
|
||||
Degraded = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin is being stopped gracefully.
|
||||
/// </summary>
|
||||
Stopping = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin has been stopped and is no longer servicing requests.
|
||||
/// </summary>
|
||||
Stopped = 6,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin initialization or operation failed.
|
||||
/// Check status message for details.
|
||||
/// </summary>
|
||||
Failed = 7,
|
||||
|
||||
/// <summary>
|
||||
/// Plugin is being unloaded from the application domain.
|
||||
/// </summary>
|
||||
Unloading = 8
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for <see cref="PluginLifecycleState"/>.
|
||||
/// </summary>
|
||||
public static class PluginLifecycleStateExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the plugin is in an operational state that can handle requests.
|
||||
/// </summary>
|
||||
public static bool IsOperational(this PluginLifecycleState state) =>
|
||||
state is PluginLifecycleState.Active or PluginLifecycleState.Degraded;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the plugin is in a terminal state (stopped, failed, unloading).
|
||||
/// </summary>
|
||||
public static bool IsTerminal(this PluginLifecycleState state) =>
|
||||
state is PluginLifecycleState.Stopped or PluginLifecycleState.Failed or PluginLifecycleState.Unloading;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the plugin is in a transitional state (loading, initializing, stopping).
|
||||
/// </summary>
|
||||
public static bool IsTransitioning(this PluginLifecycleState state) =>
|
||||
state is PluginLifecycleState.Loading or PluginLifecycleState.Initializing or
|
||||
PluginLifecycleState.Stopping or PluginLifecycleState.Unloading;
|
||||
|
||||
/// <summary>
|
||||
/// Returns the storage string representation.
|
||||
/// </summary>
|
||||
public static string ToStorageString(this PluginLifecycleState state) =>
|
||||
state.ToString().ToLowerInvariant();
|
||||
|
||||
/// <summary>
|
||||
/// Parses a storage string back to enum value.
|
||||
/// </summary>
|
||||
public static PluginLifecycleState ParseFromStorage(string value) =>
|
||||
Enum.Parse<PluginLifecycleState>(value, ignoreCase: true);
|
||||
}
|
||||
Reference in New Issue
Block a user