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
idGuidcodeSourceCodeSourcemimeTypestringengineIEnginetopicstringgroupstringcreatedAtDateTimeloggerILogger<Worker>historyList<HistoryEntry>
Properties
CodeSource
The source of the worker's code.
public CodeSource CodeSource { get; }
Property Value
CreatedAt
The timestamp when this worker was created.
public DateTime CreatedAt { get; }
Property Value
Group
The optional group ID for worker coordination.
public string? Group { get; }
Property Value
History
The history of code changes for this worker.
public List<HistoryEntry> History { get; }
Property Value
Id
The unique identifier of this worker.
public Guid Id { get; }
Property Value
MimeType
The MIME type of the worker's code.
public string MimeType { get; }
Property Value
Status
The current status of the worker.
public WorkerStatus Status { get; set; }
Property Value
Topic
The topic this worker subscribes to.
public string Topic { get; }
Property Value
Methods
LoadCodeAsync(byte[], CancellationToken)
Loads code into the worker's engine.
public Task LoadCodeAsync(byte[] blob, CancellationToken cancellationToken = default)
Parameters
blobbyte[]The code blob to load.
cancellationTokenCancellationTokenCancellation token.
Returns
ProcessAsync(CloudEvent, CancellationToken)
Processes a cloud event through the worker's engine.
public Task<CloudEvent?> ProcessAsync(CloudEvent input, CancellationToken cancellationToken = default)
Parameters
inputCloudEventThe incoming cloud event.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<CloudEvent>
The response cloud event, or
nullif no response.