Table of Contents

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

stateClient State.StateClient
httpClientFactory IHttpClientFactory
logger ILogger<WorkManager>
instanceIdProvider IInstanceIdProvider
allowedCodeSourceHosts string

Fields

CodeFetcherHttpClientName

public const string CodeFetcherHttpClientName = "CodeFetcher"

Field Value

string

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

id Guid
key string
cancellationToken CancellationToken

Returns

Task<string>

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

id Guid
cancellationToken CancellationToken

Returns

Task<IReadOnlyDictionary<string, string>>

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

id Guid
cancellationToken CancellationToken

Returns

Task<IReadOnlyList<HistoryEntry>>

Exceptions

WorkerNotFoundException

No such worker.

ListWorkersAsync(CancellationToken)

Every persisted worker, with its current status.

public Task<IReadOnlyList<WorkerInfo>> ListWorkersAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<IReadOnlyList<WorkerInfo>>

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

id Guid
key string
value string
cancellationToken CancellationToken

Returns

Task

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

id Guid
tags IDictionary<string, string>
cancellationToken CancellationToken

Returns

Task

Exceptions

WorkerNotFoundException

No such worker.