Class ObservableQueryHandler
- Namespace
- Cratis.Arc.Queries
- Assembly
- Cratis.Arc.Core.dll
Represents a generic implementation of IObservableQueryHandler that doesn't depend on specific HTTP frameworks.
[Singleton]
public class ObservableQueryHandler : IObservableQueryHandler
- Inheritance
-
ObservableQueryHandler
- Implements
- Inherited Members
- Extension Methods
Constructors
ObservableQueryHandler(IQueryContextManager, IServiceProvider, ILogger<ObservableQueryHandler>)
Represents a generic implementation of IObservableQueryHandler that doesn't depend on specific HTTP frameworks.
public ObservableQueryHandler(IQueryContextManager queryContextManager, IServiceProvider serviceProvider, ILogger<ObservableQueryHandler> logger)
Parameters
queryContextManagerIQueryContextManagerserviceProviderIServiceProviderloggerILogger<ObservableQueryHandler>ILogger for logging.
Methods
HandleStreamingResult(IHttpRequestContext, QueryName, object)
Handles a streaming query result for WebSocket connections.
public Task HandleStreamingResult(IHttpRequestContext context, QueryName queryName, object streamingData)
Parameters
contextIHttpRequestContextThe IHttpRequestContext.
queryNameQueryNameThe name of the query being executed.
streamingDataobjectThe streaming data (Subject or AsyncEnumerable).
Returns
IsStreamingResult(object?)
Determines if the given data is a streaming result that can be handled via WebSocket.
public bool IsStreamingResult(object? data)
Parameters
dataobjectThe data to check.
Returns
- bool
True if the data is a streaming result, false otherwise.
ShouldHandleAsSSE(IHttpRequestContext)
Determines if the current request should be handled as a Server-Sent Events (SSE) connection.
public bool ShouldHandleAsSSE(IHttpRequestContext context)
Parameters
contextIHttpRequestContextThe IHttpRequestContext.
Returns
- bool
True if the request should be handled as SSE, false otherwise.
ShouldHandleAsWebSocket(IHttpRequestContext)
Determines if the current request should be handled as a WebSocket connection.
public bool ShouldHandleAsWebSocket(IHttpRequestContext context)
Parameters
contextIHttpRequestContextThe IHttpRequestContext.
Returns
- bool
True if the request should be handled as WebSocket, false otherwise.