Share via


SseResultExtensions.ToSseResult<T> Method

Definition

Converts an async enumerable source to an SSE result with frame transformation.

public static Azure.AI.AgentServer.Core.Common.Http.ServerSentEvent.SseResult ToSseResult<T>(this System.Collections.Generic.IAsyncEnumerable<T> source, Func<T,Azure.AI.AgentServer.Core.Common.Http.ServerSentEvent.SseFrame> frameTransformer, Microsoft.Extensions.Logging.ILogger logger, System.Threading.CancellationToken ct = default, TimeSpan? keepAliveInterval = default);
static member ToSseResult : System.Collections.Generic.IAsyncEnumerable<'T> * Func<'T, Azure.AI.AgentServer.Core.Common.Http.ServerSentEvent.SseFrame> * Microsoft.Extensions.Logging.ILogger * System.Threading.CancellationToken * Nullable<TimeSpan> -> Azure.AI.AgentServer.Core.Common.Http.ServerSentEvent.SseResult
<Extension()>
Public Function ToSseResult(Of T) (source As IAsyncEnumerable(Of T), frameTransformer As Func(Of T, SseFrame), logger As ILogger, Optional ct As CancellationToken = Nothing, Optional keepAliveInterval As Nullable(Of TimeSpan) = Nothing) As SseResult

Type Parameters

T

The type of items in the source sequence.

Parameters

source
IAsyncEnumerable<T>

The source async enumerable.

frameTransformer
Func<T,SseFrame>

Function to transform source items to SSE frames.

logger
ILogger

Logger for diagnostic information.

ct
CancellationToken

Cancellation token.

keepAliveInterval
Nullable<TimeSpan>

Optional keep-alive interval.

Returns

An SSE result that can be returned from an endpoint.

Applies to