Table of Contents

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

inner IContainerManager
instanceStore IInstanceStore
orchestratorOptions OrchestratorOptions
logger ILogger<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

int

Properties

HostAddress

public string HostAddress { get; }

Property Value

string

ProviderName

public string ProviderName { get; }

Property Value

string

Methods

CreateAsync(CreateContainerRequest, CancellationToken)

Creates a new container.

public Task<string> CreateAsync(CreateContainerRequest request, CancellationToken cancellationToken = default)

Parameters

request CreateContainerRequest
cancellationToken CancellationToken

Returns

Task<string>

GetAsync(string, CancellationToken)

Gets detailed information about a specific container.

public Task<ContainerInfo?> GetAsync(string containerId, CancellationToken cancellationToken = default)

Parameters

containerId string
cancellationToken CancellationToken

Returns

Task<ContainerInfo>

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

containerId string
stdout bool
stderr bool
cancellationToken CancellationToken

Returns

Task<string>

ListAsync(bool, CancellationToken)

Lists all containers.

public Task<IReadOnlyList<ContainerInfo>> ListAsync(bool all = false, CancellationToken cancellationToken = default)

Parameters

all bool
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<ContainerInfo>>

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

containerId string
force bool
removeVolumes bool
cancellationToken CancellationToken

Returns

Task

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

containerId string

The container identifier or group name to scale.

replicas int

The desired number of instances.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

StartAsync(string, CancellationToken)

Starts a container.

public Task StartAsync(string containerId, CancellationToken cancellationToken = default)

Parameters

containerId string
cancellationToken CancellationToken

Returns

Task

StopAsync(string, TimeSpan?, CancellationToken)

Stops a container.

public Task StopAsync(string containerId, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

containerId string
timeout TimeSpan?
cancellationToken CancellationToken

Returns

Task