Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This file contains the handlers that are used within websocket server.
This module export three main handlers for the websocket server (onConn
,
onMessage
, onClose
), and two helpers for sending messages to the client
(sendMsg
, sendCloseWithMsg
).
NOTE!
The handler functions onClose
, onMessage
, etc. depend for correctness on two properties:
- they run with async exceptions masked
- they do not race on the same connection
Synopsis
- sendMsg :: MonadIO m => WSConn -> ServerMsg -> m ()
- sendCloseWithMsg :: MonadIO m => Logger Hasura -> WSConn -> ServerErrorCode -> Maybe ServerMsg -> Maybe Word16 -> m ()
- onConn :: (MonadIO m, MonadReader (WSServerEnv impl) m) => OnConnH m WSConnData
- onMessage :: (MonadIO m, UserAuthentication m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadExecutionLog m, MonadExecuteQuery m, MonadBaseControl IO m, MonadMetadataStorage m, MonadQueryTags m, HasResourceLimits m, ProvidesNetwork m, MonadTrace m, MonadGetPolicies m) => HashSet (EngineLogType Hasura) -> IO AuthMode -> WSServerEnv impl -> WSConn -> ByteString -> WSActions WSConnData -> Maybe (CredentialCache AgentLicenseKey) -> m ()
- onClose :: MonadIO m => Logger Hasura -> ServerMetrics -> PrometheusMetrics -> SubscriptionsState -> WSConn -> IO GranularPrometheusMetricsState -> m ()
- data WebsocketCloseOnMetadataChangeAction
- mkCloseWebsocketsOnMetadataChangeAction :: WSServer WSConnData -> WebsocketCloseOnMetadataChangeAction
Documentation
sendCloseWithMsg :: MonadIO m => Logger Hasura -> WSConn -> ServerErrorCode -> Maybe ServerMsg -> Maybe Word16 -> m () Source #
onConn :: (MonadIO m, MonadReader (WSServerEnv impl) m) => OnConnH m WSConnData Source #
onMessage :: (MonadIO m, UserAuthentication m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadExecutionLog m, MonadExecuteQuery m, MonadBaseControl IO m, MonadMetadataStorage m, MonadQueryTags m, HasResourceLimits m, ProvidesNetwork m, MonadTrace m, MonadGetPolicies m) => HashSet (EngineLogType Hasura) -> IO AuthMode -> WSServerEnv impl -> WSConn -> ByteString -> WSActions WSConnData -> Maybe (CredentialCache AgentLicenseKey) -> m () Source #
onClose :: MonadIO m => Logger Hasura -> ServerMetrics -> PrometheusMetrics -> SubscriptionsState -> WSConn -> IO GranularPrometheusMetricsState -> m () Source #
mkCloseWebsocketsOnMetadataChangeAction :: WSServer WSConnData -> WebsocketCloseOnMetadataChangeAction Source #
By default, we close all the websocket connections when the metadata changes. This function is used to create the action that will be run when the metadata changes.