// Copyright (c) The Geekeey Authors
// SPDX-License-Identifier: EUPL-1.2
#pragma warning disable CA1711
#pragma warning disable CA1716
namespace Geekeey.Request.Dispatcher;
///
/// Represents a behavior in the request pipeline, allowing interception, modification,
/// or chaining of asynchronous stream requests and responses.
///
/// The type of the request being processed. Must implement .
/// The type of the response produced by the implementing request handler.
public interface IStreamRequestBehavior where TRequest : IStreamRequest
{
///
/// Handles the asynchronous processing of a request, allowing behavior customization
/// such as interception, modification, or chaining of the request and its response.
///
/// The request instance being processed.
/// The next delegate in the pipeline to execute after the custom behavior.
/// A token to monitor for cancellation requests.
/// An asynchronous stream of representing the processed response.
IAsyncEnumerable HandleAsync(TRequest request, StreamHandlerDelegate next, CancellationToken cancellationToken);
}
///
/// Represents the delegate responsible for handling asynchronous requests in a pipeline.
///
/// The type of the response produced by the implementing request handler.
/// The asynchronous request being processed.
/// A token for monitoring cancellation requests.
/// An asynchronous stream of responses of type .
public delegate IAsyncEnumerable StreamHandlerDelegate(IStreamRequest request, CancellationToken cancellationToken);