Interface IAsyncObserver<T>
This interface generalizes the standard .NET IObserver interface to allow asynchronous production of items.
Note that this interface is implemented by item consumers and invoked (used) by item producers. This means that the consumer endpoint of a stream implements this interface.
Namespace: Orleans.Streams
Assembly: Orleans.Core.Abstractions.dll
Syntax
public interface IAsyncObserver<in T>
Type Parameters
| Name | Description |
|---|---|
| T | The type of object consumed by the observer. |
Methods
| Improve this Doc View SourceOnCompletedAsync()
Notifies the consumer that the stream was completed.
The Task returned from this method should be completed when the consumer is done processing the stream closure.
Declaration
Task OnCompletedAsync()
Returns
| Type | Description |
|---|---|
| Task | A Task that is completed when the stream-complete operation has been accepted. |
OnErrorAsync(Exception)
Notifies the consumer that the stream had an error.
The Task returned from this method should be completed when the consumer is done processing the stream closure.
Declaration
Task OnErrorAsync(Exception ex)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | ex | An Exception that describes the error that occured on the stream. |
Returns
| Type | Description |
|---|---|
| Task | A Task that is completed when the close has been accepted. |
OnNextAsync(T, StreamSequenceToken)
Passes the next item to the consumer.
The Task returned from this method should be completed when the item's processing has been sufficiently processed by the consumer to meet any behavioral guarantees.
When the consumer is the (producer endpoint of) a stream, the Task is completed when the stream implementation has accepted responsibility for the item and is assured of meeting its delivery guarantees. For instance, a stream based on a durable queue would complete the Task when the item has been durably saved. A stream that provides best-effort at most once delivery would return a Task that is already complete.
When the producer is the (consumer endpoint of) a stream, the Task should be completed by the consumer code when it has accepted responsibility for the item. In particular, if the stream provider guarantees at-least-once delivery, then the item should not be considered delivered until the Task returned by the consumer has been completed.
Declaration
Task OnNextAsync(T item, StreamSequenceToken token = null)
Parameters
| Type | Name | Description |
|---|---|---|
| T | item | The item to be passed. |
| StreamSequenceToken | token | The stream sequence token of this item. |
Returns
| Type | Description |
|---|---|
| Task | A Task that is completed when the item has been accepted. |