Class WorkManager
- Namespace
- Virtufin.WorkManager.Components
- Assembly
- Virtufin.WorkManager.dll
The worker catalog: every worker's persisted WorkerConfig (code source, topics, config, tags, history, status) and the worker index. The WorkManager runs no worker code; execution lives in the WorkManager.Runtime actors (Virtufin.WorkManager.Shared.Actors.RuntimeActorTypeNames).
Every read-modify-write of a record is an etag compare-and-swap (UpdateWorkerConfigAsync(Guid, Func<WorkerConfig, WorkerConfig>, CancellationToken)), so the WorkManager replicas and the load coordinator can write the same record concurrently without losing an update.
public sealed class WorkManager
- Inheritance
-
WorkManager
- Inherited Members
Constructors
WorkManager(StateClient, IHttpClientFactory, ILogger<WorkManager>, IInstanceIdProvider, string?)
public WorkManager(State.StateClient stateClient, IHttpClientFactory httpClientFactory, ILogger<WorkManager> logger, IInstanceIdProvider instanceIdProvider, string? allowedCodeSourceHosts = null)
Parameters
stateClientState.StateClienthttpClientFactoryIHttpClientFactoryloggerILogger<WorkManager>instanceIdProviderIInstanceIdProviderallowedCodeSourceHostsstring
Fields
CodeFetcherHttpClientName
public const string CodeFetcherHttpClientName = "CodeFetcher"
Field Value
Methods
GetTagAsync(Guid, string, CancellationToken)
The worker's value for one tag, or null if unset.
public Task<string?> GetTagAsync(Guid id, string key, CancellationToken cancellationToken)
Parameters
idGuidkeystringcancellationTokenCancellationToken
Returns
Exceptions
- WorkerNotFoundException
No such worker.
GetTagsAsync(Guid, CancellationToken)
A snapshot of the worker's tag map.
public Task<IReadOnlyDictionary<string, string>> GetTagsAsync(Guid id, CancellationToken cancellationToken)
Parameters
idGuidcancellationTokenCancellationToken
Returns
Exceptions
- WorkerNotFoundException
No such worker.
GetWorkerHistoryAsync(Guid, CancellationToken)
The worker's code change history, oldest first.
public Task<IReadOnlyList<HistoryEntry>> GetWorkerHistoryAsync(Guid id, CancellationToken cancellationToken)
Parameters
idGuidcancellationTokenCancellationToken
Returns
Exceptions
- WorkerNotFoundException
No such worker.
ListWorkersAsync(CancellationToken)
Every persisted worker, with its current status.
public Task<IReadOnlyList<WorkerInfo>> ListWorkersAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationToken
Returns
SetTagAsync(Guid, string, string, CancellationToken)
Sets one tag. Tags are catalog metadata; the worker never sees them.
public Task SetTagAsync(Guid id, string key, string value, CancellationToken cancellationToken)
Parameters
idGuidkeystringvaluestringcancellationTokenCancellationToken
Returns
Exceptions
- WorkerNotFoundException
No such worker.
SetTagsAsync(Guid, IDictionary<string, string>, CancellationToken)
Replaces the worker's whole tag map.
public Task SetTagsAsync(Guid id, IDictionary<string, string> tags, CancellationToken cancellationToken)
Parameters
idGuidtagsIDictionary<string, string>cancellationTokenCancellationToken
Returns
Exceptions
- WorkerNotFoundException
No such worker.