Table of Contents

Class FeatureStreamEventBuffer

Namespace
Honua.Sdk.Abstractions.Features
Assembly
Honua.Sdk.Abstractions.dll

Browser-safe bounded buffer for normalized feature stream events.

public sealed class FeatureStreamEventBuffer : IDisposable
Inheritance
FeatureStreamEventBuffer
Implements
Inherited Members

Constructors

FeatureStreamEventBuffer(FeatureStreamBackpressureOptions?, FeatureStreamEventProcessor?)

Initializes a new instance of the FeatureStreamEventBuffer class.

public FeatureStreamEventBuffer(FeatureStreamBackpressureOptions? options = null, FeatureStreamEventProcessor? processor = null)

Parameters

options FeatureStreamBackpressureOptions

Bounded buffer options.

processor FeatureStreamEventProcessor

Optional sequence processor used before events enter the buffer.

Methods

Complete()

Completes the buffer and wakes pending readers and writers.

public void Complete()

Remarks

When the queue is empty a single reader wakeup is released; that reader observes completion and passes the wakeup on to the next blocked reader (baton passing) so all blocked readers drain. A writer parked in Wait mode is woken by releasing _space; it then observes completion under the gate and returns Completed instead of faulting.

Dispose()

Completes the buffer and releases synchronization resources.

public void Dispose()

ReadAllAsync(CancellationToken)

Reads buffered events until the buffer is completed or cancellation is requested.

public IAsyncEnumerable<FeatureStreamEvent> ReadAllAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

IAsyncEnumerable<FeatureStreamEvent>

Buffered events.

TryWrite(FeatureStreamEvent)

Attempts to write an event without waiting for buffer capacity.

public FeatureStreamBufferWriteResult TryWrite(FeatureStreamEvent featureEvent)

Parameters

featureEvent FeatureStreamEvent

Event to write.

Returns

FeatureStreamBufferWriteResult

Write result.

WriteAsync(FeatureStreamEvent, CancellationToken)

Writes an event, waiting for capacity when the mode is Wait.

public ValueTask<FeatureStreamBufferWriteResult> WriteAsync(FeatureStreamEvent featureEvent, CancellationToken cancellationToken = default)

Parameters

featureEvent FeatureStreamEvent

Event to write.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<FeatureStreamBufferWriteResult>

Write result.