Class StateTrackingContainerManagerDecorator
- Namespace
- Bielu.Microservices.Orchestrator.Storage
- Assembly
- Bielu.Microservices.Orchestrator.dll
Decorator for IContainerManager that automatically persists desired state to an IInstanceStore on lifecycle operations. This keeps all provider implementations untouched.
public class StateTrackingContainerManagerDecorator : IContainerManager
- Inheritance
-
StateTrackingContainerManagerDecorator
- Implements
- Inherited Members
Remarks
The containerId parameter on lifecycle methods is treated as the
Id (typically the user-supplied
Name). The decorator looks up the
corresponding store record to apply state transitions; if no record is found,
the parameter is forwarded as-is to the inner manager and no store update is
performed.
Constructors
StateTrackingContainerManagerDecorator(IContainerManager, IInstanceStore, OrchestratorOptions, ILogger<StateTrackingContainerManagerDecorator>)
Decorator for IContainerManager that automatically persists desired state to an IInstanceStore on lifecycle operations. This keeps all provider implementations untouched.
public StateTrackingContainerManagerDecorator(IContainerManager inner, IInstanceStore instanceStore, OrchestratorOptions orchestratorOptions, ILogger<StateTrackingContainerManagerDecorator> logger)
Parameters
innerIContainerManagerinstanceStoreIInstanceStoreorchestratorOptionsOrchestratorOptionsloggerILogger<StateTrackingContainerManagerDecorator>
Remarks
The containerId parameter on lifecycle methods is treated as the
Id (typically the user-supplied
Name). The decorator looks up the
corresponding store record to apply state transitions; if no record is found,
the parameter is forwarded as-is to the inner manager and no store update is
performed.
Fields
DecoratorPriority
Deferred decorator priority for the state-tracking decorator. Applied close to the provider (low value = inner wrapper).
public const int DecoratorPriority = 100
Field Value
Properties
HostAddress
public string HostAddress { get; }
Property Value
ProviderName
public string ProviderName { get; }
Property Value
Methods
CreateAsync(CreateContainerRequest, CancellationToken)
Creates a new container.
public Task<string> CreateAsync(CreateContainerRequest request, CancellationToken cancellationToken = default)
Parameters
requestCreateContainerRequestcancellationTokenCancellationToken
Returns
GetAsync(string, CancellationToken)
Gets detailed information about a specific container.
public Task<ContainerInfo?> GetAsync(string containerId, CancellationToken cancellationToken = default)
Parameters
containerIdstringcancellationTokenCancellationToken
Returns
GetLogsAsync(string, bool, bool, CancellationToken)
Gets the logs for a container.
public Task<string> GetLogsAsync(string containerId, bool stdout = true, bool stderr = true, CancellationToken cancellationToken = default)
Parameters
containerIdstringstdoutboolstderrboolcancellationTokenCancellationToken
Returns
ListAsync(bool, CancellationToken)
Lists all containers.
public Task<IReadOnlyList<ContainerInfo>> ListAsync(bool all = false, CancellationToken cancellationToken = default)
Parameters
allboolcancellationTokenCancellationToken
Returns
RemoveAsync(string, bool, bool, CancellationToken)
Removes a container.
When removeVolumes is true, also deletes all data associated
with the container: anonymous volumes, named volumes, and bind-mounted host directories.
public Task RemoveAsync(string containerId, bool force = false, bool removeVolumes = false, CancellationToken cancellationToken = default)
Parameters
containerIdstringforceboolremoveVolumesboolcancellationTokenCancellationToken
Returns
ScaleAsync(string, int, CancellationToken)
Scales the number of instances for a container or container group. Not all runtimes support scaling; providers that do not will throw NotSupportedException.
public Task ScaleAsync(string containerId, int replicas, CancellationToken cancellationToken = default)
Parameters
containerIdstringThe container identifier or group name to scale.
replicasintThe desired number of instances.
cancellationTokenCancellationTokenCancellation token.
Returns
StartAsync(string, CancellationToken)
Starts a container.
public Task StartAsync(string containerId, CancellationToken cancellationToken = default)
Parameters
containerIdstringcancellationTokenCancellationToken
Returns
StopAsync(string, TimeSpan?, CancellationToken)
Stops a container.
public Task StopAsync(string containerId, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
containerIdstringtimeoutTimeSpan?cancellationTokenCancellationToken