2026-05-08 20:26:26 +02:00
|
|
|
// Copyright (c) The Geekeey Authors
|
|
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
2026-05-29 22:53:58 +02:00
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
2026-05-08 20:26:26 +02:00
|
|
|
namespace Geekeey.Request.Dispatcher.Tests;
|
|
|
|
|
|
|
|
|
|
public class StreamOpenBehavior<TRequest, TResponse>(StreamTestTracker tracker) : IStreamRequestBehavior<TRequest, TResponse>
|
|
|
|
|
where TRequest : IStreamRequest<TResponse>
|
|
|
|
|
{
|
2026-05-29 22:53:58 +02:00
|
|
|
public async IAsyncEnumerable<TResponse> HandleAsync(TRequest request, StreamHandlerDelegate<TResponse> next, [EnumeratorCancellation] CancellationToken cancellationToken)
|
2026-05-08 20:26:26 +02:00
|
|
|
{
|
|
|
|
|
tracker.Executed = true;
|
2026-05-29 22:53:58 +02:00
|
|
|
await foreach (var response in next(request, cancellationToken))
|
|
|
|
|
{
|
|
|
|
|
yield return response;
|
|
|
|
|
}
|
2026-05-08 20:26:26 +02:00
|
|
|
}
|
|
|
|
|
}
|