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