request/src/request.dispatcher/IScalarRequestHandler.cs

20 lines
1.1 KiB
C#

// Copyright (c) The Geekeey Authors
// SPDX-License-Identifier: EUPL-1.2
namespace Geekeey.Request.Dispatcher;
/// <summary>
/// Defines a handler for processing requests of a specific type and returning a response.
/// </summary>
/// <typeparam name="TRequest">The type of the request to be handled. Must implement <see cref="IScalarRequest{TResponse}"/>.</typeparam>
/// <typeparam name="TResponse">The type of the response produced by the implementing request handler.</typeparam>
public interface IScalarRequestHandler<in TRequest, TResponse> where TRequest : IScalarRequest<TResponse>
{
/// <summary>
/// Processes a scalar request and returns a response asynchronously.
/// </summary>
/// <param name="request">The request object to be processed.</param>
/// <param name="cancellationToken">A token to observe for cancellation requests.</param>
/// <returns>A task representing the asynchronous operation, containing the response of type <typeparamref name="TResponse"/>.</returns>
Task<TResponse> HandleAsync(TRequest request, CancellationToken cancellationToken = default);
}