StellaOps.Workflow.Signaling.Redis
Redis signal driver for the workflow engine: delivers wake messages when signals are stored.
| Package | StellaOps.Workflow.Signaling.Redis |
| Component | Workflow |
| Licence | BUSL-1.1 (Workflow licence) |
| Package kind | Library |
| Target framework | net10.0 |
To add the package to a project, see Installing Stella Ops packages.
Namespaces
| Namespace | Types |
|---|---|
StellaOps.Workflow.Signaling.Redis | 7 |
StellaOps.Workflow.Signaling.Redis namespace
| Type | Kind | Description |
|---|---|---|
RedisWorkflowSignalDriver | class | The Redis signal driver: it publishes a wake message on a Redis channel after the workflow changes commit, and claims the signals from the durable store when a wake arrives or the blocking wait ends. |
RedisWorkflowSignalDriverOptions | class | Settings of the Redis signal driver (WorkflowSignalDriver:Redis). |
RedisWorkflowSignalingExtensions | class | Registers the Redis signal driver. |
RedisWorkflowSignalingRoutine | class | Dependency-injection routine of the Redis signal driver. |
RedisWorkflowWakeMessageSerializer | class | Writes and reads the wake messages of the Redis channel. |
RedisWorkflowWakeSubscription | class | The subscription to the Redis wake channel. |
WorkflowRedisHealthCheck | class | Reports whether the Redis wake signaling is connected. |
RedisWorkflowSignalDriver class
public sealed class RedisWorkflowSignalDriver : IWorkflowSignalDriver
The Redis signal driver: it publishes a wake message on a Redis channel after the workflow changes commit, and claims the signals from the durable store when a wake arrives or the blocking wait ends.
Parameters
connectionMultiplexer: The Redis connection.signalClaimStore: Claims the stored signals.wakeSubscription: Receives the wake messages.driverOptions: The channel name and the blocking wait.
RedisWorkflowSignalDriver(IConnectionMultiplexer, IWorkflowSignalClaimStore, RedisWorkflowWakeSubscription, IOptions<RedisWorkflowSignalDriverOptions>) constructor
public RedisWorkflowSignalDriver(IConnectionMultiplexer connectionMultiplexer, IWorkflowSignalClaimStore signalClaimStore, RedisWorkflowWakeSubscription wakeSubscription, IOptions<RedisWorkflowSignalDriverOptions> driverOptions)
The Redis signal driver: it publishes a wake message on a Redis channel after the workflow changes commit, and claims the signals from the durable store when a wake arrives or the blocking wait ends.
Parameters
connectionMultiplexer: The Redis connection.signalClaimStore: Claims the stored signals.wakeSubscription: Receives the wake messages.driverOptions: The channel name and the blocking wait.
DispatchMode property
public WorkflowSignalDriverDispatchMode DispatchMode { get; }
When the engine tells the driver that a signal is available.
DriverName property
public string DriverName { get; }
The driver name, as WorkflowSignalDriver:Provider selects it.
NotifySignalAvailableAsync(WorkflowSignalWakeNotification, CancellationToken) method
public Task NotifySignalAvailableAsync(WorkflowSignalWakeNotification notification, CancellationToken cancellationToken = default)
Tells the consumers that a signal is available.
Parameters
notification: The available signal.cancellationToken: Cancels the operation.
Returns
A task that completes when the notification is sent.
ReceiveAsync(string, CancellationToken) method
public Task<IWorkflowSignalLease?> ReceiveAsync(string consumerName, CancellationToken cancellationToken = default)
Waits up to the driver’s blocking wait for a signal to claim.
Parameters
consumerName: The consumer.cancellationToken: Cancels the operation.
Returns
The lease of the claimed signal, or null when none arrives in time.
RedisWorkflowSignalDriverOptions class
public sealed class RedisWorkflowSignalDriverOptions
Settings of the Redis signal driver (WorkflowSignalDriver:Redis).
RedisWorkflowSignalDriverOptions() constructor
public RedisWorkflowSignalDriverOptions()
Creates an instance of RedisWorkflowSignalDriverOptions.
SectionName constant
public const string SectionName = "WorkflowSignalDriver:Redis"
The configuration section the options bind from: WorkflowSignalDriver:Redis.
BlockingWaitSeconds property
public int BlockingWaitSeconds { get; set; }
How long a receive waits for a signal before it returns empty, in seconds; a value below 1 counts as 1. The default is 30.
ChannelName property
public string ChannelName { get; set; }
The Redis channel that announces new signals. The default is stellaops:workflow:signals.
RedisWorkflowSignalingExtensions class
public static class RedisWorkflowSignalingExtensions
Registers the Redis signal driver.
AddWorkflowRedisSignaling(IServiceCollection, IConfiguration) extension method
public static IServiceCollection AddWorkflowRedisSignaling(this IServiceCollection services, IConfiguration configuration)
Registers the Redis signal driver, bound from WorkflowSignalDriver:Redis, when WorkflowSignalDriver:Provider is Redis; otherwise it only records the driver module.
Parameters
services: The service collection to add the services to.configuration: The host configuration.
Returns
The same service collection, for chaining.
RedisWorkflowSignalingRoutine class
public sealed class RedisWorkflowSignalingRoutine : IDependencyInjectionRoutine
Dependency-injection routine of the Redis signal driver. A host that loads this assembly as a plugin discovers the routine; it registers exactly what RedisWorkflowSignalingExtensions.AddWorkflowRedisSignaling(IServiceCollection, IConfiguration)registers. The host still provides the IConnectionMultiplexer, as it does for a package reference.
RedisWorkflowSignalingRoutine() constructor
public RedisWorkflowSignalingRoutine()
Creates an instance of RedisWorkflowSignalingRoutine.
Register(IServiceCollection, IConfiguration) method
public IServiceCollection Register(IServiceCollection services, IConfiguration configuration)
Registers what RedisWorkflowSignalingExtensions.AddWorkflowRedisSignaling(IServiceCollection, IConfiguration)registers.
Parameters
services: The service collection.configuration: The host configuration.
Returns
The same service collection.
RedisWorkflowWakeMessageSerializer class
public static class RedisWorkflowWakeMessageSerializer
Writes and reads the wake messages of the Redis channel.
Deserialize(string) method
public static WorkflowSignalWakeNotification Deserialize(string payload)
Reads a wake notification from JSON.
Parameters
payload: The JSON message.
Returns
The notification.
Exceptions
InvalidOperationException: The message is JSON null.
Serialize(WorkflowSignalWakeNotification) method
public static string Serialize(WorkflowSignalWakeNotification notification)
Writes a wake notification as JSON.
Parameters
notification: The notification.
Returns
The JSON message.
RedisWorkflowWakeSubscription class
public sealed class RedisWorkflowWakeSubscription : IDisposable, IAsyncDisposable
The subscription to the Redis wake channel.
Parameters
connectionMultiplexer: The Redis connection.driverOptions: The channel name.
RedisWorkflowWakeSubscription(IConnectionMultiplexer, IOptions<RedisWorkflowSignalDriverOptions>) constructor
public RedisWorkflowWakeSubscription(IConnectionMultiplexer connectionMultiplexer, IOptions<RedisWorkflowSignalDriverOptions> driverOptions)
The subscription to the Redis wake channel.
Parameters
connectionMultiplexer: The Redis connection.driverOptions: The channel name.
Dispose() method
public void Dispose()
Unsubscribes from the channel.
DisposeAsync() method
public ValueTask DisposeAsync()
Unsubscribes from the channel.
Returns
A task that completes when the subscription is closed.
WaitForNotificationAsync(TimeSpan, CancellationToken) method
public Task<WorkflowSignalWakeNotification?> WaitForNotificationAsync(TimeSpan maxWait, CancellationToken cancellationToken = default)
Waits for the next wake message, subscribing to the channel on first use.
Parameters
maxWait: How long to wait.cancellationToken: Cancels the operation.
Returns
The notification, or null when none arrives in time.
WorkflowRedisHealthCheck class
public sealed class WorkflowRedisHealthCheck : IHealthCheck
Reports whether the Redis wake signaling is connected.
Parameters
connectionMultiplexer: The Redis connection.
WorkflowRedisHealthCheck(IConnectionMultiplexer) constructor
public WorkflowRedisHealthCheck(IConnectionMultiplexer connectionMultiplexer)
Reports whether the Redis wake signaling is connected.
Parameters
connectionMultiplexer: The Redis connection.
CheckHealthAsync(HealthCheckContext, CancellationToken) method
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
Pings Redis: healthy with the latency when connected, unhealthy otherwise.
Parameters
context: The health check context.cancellationToken: Cancels the operation.
Returns
The health check result.
