Safe Haskell | None |
---|---|
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
- data OpDetail
- = ODStarted
- | ODProtoErr !Text
- | ODQueryErr !QErr
- | ODCompleted
- | ODStopped
- data OperationDetails = OperationDetails {}
- data WSEvent
- data WsConnInfo = WsConnInfo {
- _wsciWebsocketId :: !WSId
- _wsciTokenExpiry :: !(Maybe UTCTime)
- _wsciMsg :: !(Maybe Text)
- data WSLogInfo = WSLogInfo {}
- data WSLog = WSLog {
- _wslLogLevel :: !LogLevel
- _wslInfo :: !WSLogInfo
- mkWsInfoLog :: Maybe SessionVariables -> WsConnInfo -> WSEvent -> WSLog
- mkWsErrorLog :: Maybe SessionVariables -> WsConnInfo -> WSEvent -> WSLog
- logWSEvent :: MonadIO m => Logger Hasura -> WSConn -> WSEvent -> m ()
- sendMsg :: MonadIO m => WSConn -> ServerMsg -> m ()
- sendCloseWithMsg :: MonadIO m => Logger Hasura -> WSConn -> ServerErrorCode -> Maybe ServerMsg -> Maybe Word16 -> m ()
- sendMsgWithMetadata :: MonadIO m => WSConn -> ServerMsg -> Maybe OperationName -> Maybe ParameterizedQueryHash -> SubscriptionMetadata -> m ()
- onConn :: (MonadIO m, MonadReader WSServerEnv m) => OnConnH m WSConnData
- onStart :: forall m. (MonadIO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, MonadExecuteQuery m, MonadBaseControl IO m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => Environment -> HashSet (EngineLogType Hasura) -> WSServerEnv -> WSConn -> StartMsg -> WSActions WSConnData -> m ()
- onMessage :: (MonadIO m, UserAuthentication (TraceT m), MonadGQLExecutionCheck m, MonadQueryLog m, HasReporter m, MonadExecuteQuery m, MonadBaseControl IO m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => Environment -> HashSet (EngineLogType Hasura) -> AuthMode -> WSServerEnv -> WSConn -> ByteString -> WSActions WSConnData -> m ()
- onPing :: MonadIO m => WSConn -> Maybe PingPongPayload -> m ()
- onPong :: MonadIO m => WSConn -> Maybe PingPongPayload -> m ()
- onStop :: MonadIO m => WSServerEnv -> WSConn -> StopMsg -> m ()
- stopOperation :: WSServerEnv -> WSConn -> OperationId -> IO () -> IO ()
- onConnInit :: (MonadIO m, UserAuthentication (TraceT m)) => Logger Hasura -> Manager -> WSConn -> AuthMode -> Maybe ConnParams -> WSOnErrorMessageAction WSConnData -> WSKeepAliveMessageAction WSConnData -> TraceT m ()
- onClose :: MonadIO m => Logger Hasura -> ServerMetrics -> PrometheusMetrics -> SubscriptionsState -> WSConn -> m ()
Documentation
SubscriberDetails
comes from addLiveQuery
. We use
this to track a connection's operations so we can remove them from LiveQueryState
, and
log.
NOTE!: This must be kept consistent with the global LiveQueryState
, in onClose
and onStart
.
data OperationDetails Source #
data WsConnInfo Source #
WsConnInfo | |
|
mkWsInfoLog :: Maybe SessionVariables -> WsConnInfo -> WSEvent -> WSLog Source #
mkWsErrorLog :: Maybe SessionVariables -> WsConnInfo -> WSEvent -> WSLog Source #
sendCloseWithMsg :: MonadIO m => Logger Hasura -> WSConn -> ServerErrorCode -> Maybe ServerMsg -> Maybe Word16 -> m () Source #
sendMsgWithMetadata :: MonadIO m => WSConn -> ServerMsg -> Maybe OperationName -> Maybe ParameterizedQueryHash -> SubscriptionMetadata -> m () Source #
onConn :: (MonadIO m, MonadReader WSServerEnv m) => OnConnH m WSConnData Source #
onStart :: forall m. (MonadIO m, MonadGQLExecutionCheck m, MonadQueryLog m, MonadTrace m, MonadExecuteQuery m, MonadBaseControl IO m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => Environment -> HashSet (EngineLogType Hasura) -> WSServerEnv -> WSConn -> StartMsg -> WSActions WSConnData -> m () Source #
onMessage :: (MonadIO m, UserAuthentication (TraceT m), MonadGQLExecutionCheck m, MonadQueryLog m, HasReporter m, MonadExecuteQuery m, MonadBaseControl IO m, MonadMetadataStorage (MetadataStorageT m), MonadQueryTags m, HasResourceLimits m) => Environment -> HashSet (EngineLogType Hasura) -> AuthMode -> WSServerEnv -> WSConn -> ByteString -> WSActions WSConnData -> m () Source #
stopOperation :: WSServerEnv -> WSConn -> OperationId -> IO () -> IO () Source #
:: (MonadIO m, UserAuthentication (TraceT m)) | |
=> Logger Hasura | |
-> Manager | |
-> WSConn | |
-> AuthMode | |
-> Maybe ConnParams | |
-> WSOnErrorMessageAction WSConnData | this is the message handler for handling errors on initializing a from the client connection |
-> WSKeepAliveMessageAction WSConnData | this is the message handler for handling "keep-alive" messages to the client |
-> TraceT m () |
onClose :: MonadIO m => Logger Hasura -> ServerMetrics -> PrometheusMetrics -> SubscriptionsState -> WSConn -> m () Source #