Table of Contents

Class ObservableQueryHandler

Namespace
Cratis.Applications.Queries
Assembly
Cratis.Applications.dll

Represents an implementation of IObservableQueryHandler.

[Singleton]
public class ObservableQueryHandler : IObservableQueryHandler
Inheritance
ObservableQueryHandler
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the ObservableQueryHandler class.

Constructors

ObservableQueryHandler(IQueryContextManager, IOptions<JsonOptions>, ILogger<ObservableQueryHandler>)

Represents an implementation of IObservableQueryHandler.

public ObservableQueryHandler(IQueryContextManager queryContextManager, IOptions<JsonOptions> options, ILogger<ObservableQueryHandler> logger)

Parameters

queryContextManager IQueryContextManager

IQueryContextManager.

options IOptions<JsonOptions>

JsonOptions.

logger ILogger<ObservableQueryHandler>

ILogger for logging.

Remarks

Initializes a new instance of the ObservableQueryHandler class.

Methods

HandleStreamingResult(HttpContext, QueryName, object, QueryContext)

Handles a streaming query result for WebSocket connections in minimal API endpoints.

public Task HandleStreamingResult(HttpContext httpContext, QueryName queryName, object streamingData, QueryContext queryContext)

Parameters

httpContext HttpContext

The HttpContext for the request.

queryName QueryName

The name of the query being executed.

streamingData object

The streaming data (Subject or AsyncEnumerable).

queryContext QueryContext

The query context.

Returns

Task

A Task representing the asynchronous operation.

HandleStreamingResult(ActionExecutingContext, ActionExecutedContext?, ObjectResult)

Handles a streaming query result for WebSocket connections in controller actions.

public Task HandleStreamingResult(ActionExecutingContext context, ActionExecutedContext? actionExecutedContext, ObjectResult objectResult)

Parameters

context ActionExecutingContext

The ActionExecutingContext.

actionExecutedContext ActionExecutedContext

The ActionExecutedContext from the action execution.

objectResult ObjectResult

The ObjectResult containing the streaming data.

Returns

Task

A Task representing the asynchronous operation.

IsStreamingResult(object?)

Determines if the given data is a streaming result that can be handled via WebSocket.

public bool IsStreamingResult(object? data)

Parameters

data object

The data to check.

Returns

bool

True if the data is a streaming result, false otherwise.

ShouldHandleAsWebSocket(HttpContext)

Determines if the current request should be handled as a WebSocket connection.

public bool ShouldHandleAsWebSocket(HttpContext httpContext)

Parameters

httpContext HttpContext

The HttpContext.

Returns

bool

True if the request should be handled as WebSocket, false otherwise.

ShouldHandleAsWebSocket(ActionExecutingContext)

Determines if the current request should be handled as a WebSocket connection.

public bool ShouldHandleAsWebSocket(ActionExecutingContext context)

Parameters

context ActionExecutingContext

The ActionExecutingContext.

Returns

bool

True if the request should be handled as WebSocket, false otherwise.