Table of Contents

Interface IRecoverableUpdateStream<TValue>

Namespace
PushTechnology.ClientInterface.Client.Features
Assembly
Diffusion.Client.dll

An extension to IUpdateStream<TValue> that includes recovery functionality.

public interface IRecoverableUpdateStream<TValue> : IUpdateStream<TValue>

Type Parameters

TValue
Inherited Members

Remarks

A recoverable update stream wraps an IUpdateStream<TValue>, tracking topic updates and associated Tasks.

In the event that a IRecoverableUpdateStream<TValue> returns a Task that completes exceptionally, calling IsRecoverable returns true then recovery is possible.

Call RecoverAsync() to re-establish the update stream and re-play incomplete topic updates before resuming.

Construct a IRecoverableUpdateStream using Build<TValue>(string, RetryStrategy)

Example feature use

This example demonstrates use of a IRecoverableUpdateStream to update topic

my/topic
. If the topic update completes exceptionally and the exception is recoverable, the code recovers - reestablishing an IUpdateStream and delivering the failed topic update.
var topicSpec = Diffusion.NewTopicSpecification(TopicType.STRING);

var stream = session.TopicUpdate
   .NewUpdateStreamBuilder()
   .Specification(topicSpec)
   .Build("my/topic", new RetryStrategy(1_000, 10));

try {
    await stream.SetAsync("some value");
} catch ( Exception ex ) {
    if(stream.IsRecoverable){
        await stream.RecoverAsync();
    }
    else{
        throw;
    }
}

Added in version 6.10.

Properties

IsRecoverable

Checks if recovery is possible following an exception thrown by IRecoverableUpdateStream<TValue>/>.

bool IsRecoverable { get; }

Property Value

bool

The recovery check.

Remarks

Must be used prior to calling RecoverAsync().

Methods

RecoverAsync()

Reestablish the inner recovery stream. Deliver pending topic updates.

Task RecoverAsync()

Returns

Task

Remarks

If recoverable exceptions occur during recovery then pause and retry, where the pause duration and the maximum number of retries is governed by the RetryStrategy supplied to builder function Build<TValue>(string, RetryStrategy).

If non-recoverable errors occur during recovery then recovery is aborted.

If recovery fails for any reason then further recovery attempts will fail.

Exceptions

UpdateStreamRetryLimitException

If recovery is not possible with the limits of the retry strategy.

RecoverAsync(CancellationToken)

Reestablish the inner recovery stream. Deliver pending topic updates.

Task RecoverAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token used to cancel the current operation.

Returns

Task

Remarks

If recoverable exceptions occur during recovery then pause and retry, where the pause duration and the maximum number of retries is governed by the RetryStrategy supplied to builder function Build<TValue>(string, RetryStrategy).

If non-recoverable errors occur during recovery then recovery is aborted.

If recovery fails for any reason then further recovery attempts will fail.

Exceptions

UpdateStreamRetryLimitException

If recovery is not possible with the limits of the retry strategy.