Class WorkflowStreamClient
- Namespace
- Temporalio.Extensions.WorkflowStreams
- Assembly
- Temporalio.Extensions.WorkflowStreams.dll
External publisher and subscriber for a workflow-hosted stream.
public sealed class WorkflowStreamClient : IAsyncDisposable
- Inheritance
-
WorkflowStreamClient
- Implements
- Inherited Members
Remarks
Dispose asynchronously to drain buffered publications and stop subscriptions owned by this client. WARNING: Workflow Streams is experimental and may change.
Constructors
WorkflowStreamClient(ITemporalClient, string, WorkflowStreamClientOptions?)
Initializes a new instance of the WorkflowStreamClient class.
public WorkflowStreamClient(ITemporalClient client, string workflowId, WorkflowStreamClientOptions? options = null)
Parameters
clientITemporalClientTemporal client used for signals, updates, and queries.
workflowIdstringTarget workflow ID.
optionsWorkflowStreamClientOptionsClient options, snapshotted by this constructor.
Methods
DisposeAsync()
Stops owned subscriptions and drains buffered publications.
public ValueTask DisposeAsync()
Returns
- ValueTask
A value task shared by concurrent disposal calls.
FlushAsync(CancellationToken)
Flushes publications buffered before this call and waits for acknowledgement.
public Task FlushAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token for the flush operation.
Returns
- Task
A task that completes when the flush barrier is acknowledged.
FromActivity(WorkflowStreamClientOptions?)
Creates a stream client targeting the current activity's parent workflow.
public static WorkflowStreamClient FromActivity(WorkflowStreamClientOptions? options = null)
Parameters
optionsWorkflowStreamClientOptionsClient options.
Returns
- WorkflowStreamClient
A client for the activity's parent workflow.
Remarks
The activity's payload converter is used for stream items. Payload converters that require matching serialization context during deserialization are not compatible with subscriptions created from this client because published and received items have different serialization contexts.
GetOffsetAsync(CancellationToken)
Queries the current global offset.
public Task<long> GetOffsetAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenCancellation token for the query.
Returns
GetTopic(string?)
Creates a handle for a topic.
public WorkflowStreamClientTopicHandle GetTopic(string? name)
Parameters
namestringTopic name. Null is represented by the empty topic.
Returns
- WorkflowStreamClientTopicHandle
A topic handle.
GetTopic<T>(string?)
Creates a strongly typed handle for a topic.
public WorkflowStreamClientTopicHandle<T> GetTopic<T>(string? name)
Parameters
namestringTopic name. Null is represented by the empty topic.
Returns
- WorkflowStreamClientTopicHandle<T>
A topic handle.
Type Parameters
TType of values published to and received from the topic.
SubscribeAsync(WorkflowStreamSubscribeOptions?)
Creates a reusable subscription with independent state per enumeration.
public IAsyncEnumerable<WorkflowStreamItem> SubscribeAsync(WorkflowStreamSubscribeOptions? options = null)
Parameters
optionsWorkflowStreamSubscribeOptionsSubscription options, snapshotted by this call.
Returns
- IAsyncEnumerable<WorkflowStreamItem>
A reusable asynchronous stream of raw Temporal payloads.
SubscribeAsync<T>(WorkflowStreamSubscribeOptions?)
Creates a reusable, strongly typed subscription.
public IAsyncEnumerable<WorkflowStreamItem<T>> SubscribeAsync<T>(WorkflowStreamSubscribeOptions? options = null)
Parameters
optionsWorkflowStreamSubscribeOptionsSubscription options, snapshotted by this call.
Returns
- IAsyncEnumerable<WorkflowStreamItem<T>>
A reusable asynchronous stream of decoded values.
Type Parameters
TType to which each item is deserialized.