Table of Contents

Class Worker

Namespace
Virtufin.WorkManager.Runtime
Assembly
Virtufin.WorkManager.dll

Represents a worker instance that processes cloud events using an engine.

public sealed class Worker
Inheritance
Worker
Inherited Members

Constructors

Worker(Guid, CodeSource, string, IEngine, string, string?, DateTime, ILogger<Worker>, List<HistoryEntry>?)

Creates a new worker instance.

public Worker(Guid id, CodeSource codeSource, string mimeType, IEngine engine, string topic, string? group, DateTime createdAt, ILogger<Worker> logger, List<HistoryEntry>? history = null)

Parameters

id Guid
codeSource CodeSource
mimeType string
engine IEngine
topic string
group string
createdAt DateTime
logger ILogger<Worker>
history List<HistoryEntry>

Properties

CodeSource

The source of the worker's code.

public CodeSource CodeSource { get; }

Property Value

CodeSource

CreatedAt

The timestamp when this worker was created.

public DateTime CreatedAt { get; }

Property Value

DateTime

Group

The optional group ID for worker coordination.

public string? Group { get; }

Property Value

string

History

The history of code changes for this worker.

public List<HistoryEntry> History { get; }

Property Value

List<HistoryEntry>

Id

The unique identifier of this worker.

public Guid Id { get; }

Property Value

Guid

MimeType

The MIME type of the worker's code.

public string MimeType { get; }

Property Value

string

Status

The current status of the worker.

public WorkerStatus Status { get; set; }

Property Value

WorkerStatus

Topic

The topic this worker subscribes to.

public string Topic { get; }

Property Value

string

Methods

LoadCodeAsync(byte[], CancellationToken)

Loads code into the worker's engine.

public Task LoadCodeAsync(byte[] blob, CancellationToken cancellationToken = default)

Parameters

blob byte[]

The code blob to load.

cancellationToken CancellationToken

Cancellation token.

Returns

Task

ProcessAsync(CloudEvent, CancellationToken)

Processes a cloud event through the worker's engine.

public Task<CloudEvent?> ProcessAsync(CloudEvent input, CancellationToken cancellationToken = default)

Parameters

input CloudEvent

The incoming cloud event.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<CloudEvent>

The response cloud event, or null if no response.