StellaOps.Workflow.Signaling.Redis

Redis signal driver for the workflow engine: delivers wake messages when signals are stored.

PackageStellaOps.Workflow.Signaling.Redis
ComponentWorkflow
LicenceBUSL-1.1 (Workflow licence)
Package kindLibrary
Target frameworknet10.0

To add the package to a project, see Installing Stella Ops packages.

Namespaces

NamespaceTypes
StellaOps.Workflow.Signaling.Redis7

StellaOps.Workflow.Signaling.Redis namespace

TypeKindDescription
RedisWorkflowSignalDriverclassThe 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.
RedisWorkflowSignalDriverOptionsclassSettings of the Redis signal driver (WorkflowSignalDriver:Redis).
RedisWorkflowSignalingExtensionsclassRegisters the Redis signal driver.
RedisWorkflowSignalingRoutineclassDependency-injection routine of the Redis signal driver.
RedisWorkflowWakeMessageSerializerclassWrites and reads the wake messages of the Redis channel.
RedisWorkflowWakeSubscriptionclassThe subscription to the Redis wake channel.
WorkflowRedisHealthCheckclassReports 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

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

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

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

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

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

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

Returns

The notification.

Exceptions

Serialize(WorkflowSignalWakeNotification) method

public static string Serialize(WorkflowSignalWakeNotification notification)

Writes a wake notification as JSON.

Parameters

Returns

The JSON message.

RedisWorkflowWakeSubscription class

public sealed class RedisWorkflowWakeSubscription : IDisposable, IAsyncDisposable

The subscription to the Redis wake channel.

Parameters

RedisWorkflowWakeSubscription(IConnectionMultiplexer, IOptions<RedisWorkflowSignalDriverOptions>) constructor

public RedisWorkflowWakeSubscription(IConnectionMultiplexer connectionMultiplexer, IOptions<RedisWorkflowSignalDriverOptions> driverOptions)

The subscription to the Redis wake channel.

Parameters

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

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

WorkflowRedisHealthCheck(IConnectionMultiplexer) constructor

public WorkflowRedisHealthCheck(IConnectionMultiplexer connectionMultiplexer)

Reports whether the Redis wake signaling is connected.

Parameters

CheckHealthAsync(HealthCheckContext, CancellationToken) method

public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)

Pings Redis: healthy with the latency when connected, unhealthy otherwise.

Parameters

Returns

The health check result.