Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Hasura.GraphQL.Transport.WebSocket.Server
Synopsis
- data WSId
- mkUnsafeWSId :: UUID -> WSId
- data MessageDetails = MessageDetails !SerializableBlob !Int64
- data WSEvent = EMessageSent !MessageDetails
- data WSEventInfo = WSEventInfo {}
- data WSLog = WSLog !WSId !WSEvent !(Maybe WSEventInfo)
- class Monad m => MonadWSLog m where
- data WSQueueResponse = WSQueueResponse ByteString (Maybe WSEventInfo) (IO DiffTime)
- data WSConn a
- getRawWebSocketConnection :: WSConn a -> Connection
- getData :: WSConn a -> a
- getWSId :: WSConn a -> WSId
- closeConn :: WSConn a -> ByteString -> IO ()
- sendMsgAndCloseConn :: WSConn a -> Word16 -> ByteString -> ServerMsg -> IO ()
- sendMsg :: WSConn a -> WSQueueResponse -> IO ()
- data WSServer a = WSServer {
- _wssLogger :: Logger Hasura
- _wssSecuritySensitiveUserConfig :: TVar SecuritySensitiveUserConfig
- _wssStatus :: TVar (ServerStatus a)
- createWSServer :: AuthMode -> AllowListStatus -> InlinedAllowlist -> CorsPolicy -> SQLGenCtx -> HashSet ExperimentalFeature -> NamingCase -> Logger Hasura -> STM (WSServer a)
- closeAllConnectionsWithReason :: WSServer a -> String -> ByteString -> (SecuritySensitiveUserConfig -> SecuritySensitiveUserConfig) -> IO ()
- data AcceptWith a = AcceptWith !a !AcceptRequest !(WSConn a -> IO ()) !(WSConn a -> IO ())
- type WSKeepAliveMessageAction a = WSConn a -> IO ()
- type WSOnErrorMessageAction a = WSConn a -> ConnErrMsg -> WSErrorMessage -> IO ()
- data WSActions a = WSActions {
- _wsaPostExecErrMessageAction :: !(WSPostExecErrMessageAction a)
- _wsaOnErrorMessageAction :: !(WSOnErrorMessageAction a)
- _wsaConnectionCloseAction :: !(WSCloseConnAction a)
- _wsaKeepAliveAction :: !(WSKeepAliveMessageAction a)
- _wsaGetDataMessageType :: !(DataMsg -> ServerMsg)
- _wsaAcceptRequest :: !AcceptRequest
- _wsaErrorMsgFormat :: !([Encoding] -> Encoding)
- data WSErrorMessage
- mkWSServerErrorCode :: WSSubProtocol -> WSErrorMessage -> ConnErrMsg -> ServerErrorCode
- type OnConnH m a = WSId -> RequestHead -> IpAddress -> WSActions a -> m (Either RejectRequest (AcceptWith a))
- type HasuraServerApp m = IpAddress -> PendingConnection -> m ()
- data WSHandlers m a = WSHandlers (WSId -> RequestHead -> IpAddress -> WSSubProtocol -> m (Either RejectRequest (AcceptWith a))) (WSConn a -> ByteString -> WSSubProtocol -> m ()) (OnCloseH m a)
- websocketConnectionReaper :: IO (AuthMode, AllowListStatus, CorsPolicy, SQLGenCtx, HashSet ExperimentalFeature, NamingCase) -> IO SchemaCache -> WSServer a -> IO Void
- createServerApp :: (MonadIO m, MonadBaseControl IO m, Forall (Pure m), MonadWSLog m) => IO MetricsConfig -> WSConnectionInitTimeout -> WSServer a -> PrometheusMetrics -> WSHandlers m a -> HasuraServerApp m
- shutdown :: WSServer a -> IO ()
Documentation
mkUnsafeWSId :: UUID -> WSId Source #
data MessageDetails Source #
Websocket message and other details
Constructors
MessageDetails !SerializableBlob !Int64 |
Instances
ToJSON MessageDetails Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server Methods toJSON :: MessageDetails -> Value Source # toEncoding :: MessageDetails -> Encoding Source # toJSONList :: [MessageDetails] -> Value Source # toEncodingList :: [MessageDetails] -> Encoding Source # | |
Show MessageDetails Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server Methods showsPrec :: Int -> MessageDetails -> ShowS # show :: MessageDetails -> String # showList :: [MessageDetails] -> ShowS # |
Constructors
EMessageSent !MessageDetails |
data WSEventInfo Source #
Constructors
WSEventInfo | |
Fields |
Instances
ToJSON WSEventInfo Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server Methods toJSON :: WSEventInfo -> Value Source # toEncoding :: WSEventInfo -> Encoding Source # toJSONList :: [WSEventInfo] -> Value Source # toEncodingList :: [WSEventInfo] -> Encoding Source # | |
Show WSEventInfo Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server Methods showsPrec :: Int -> WSEventInfo -> ShowS # show :: WSEventInfo -> String # showList :: [WSEventInfo] -> ShowS # | |
Eq WSEventInfo Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server |
Constructors
WSLog !WSId !WSEvent !(Maybe WSEventInfo) |
class Monad m => MonadWSLog m where Source #
Methods
logWSLog :: Logger Hasura -> WSLog -> m () Source #
Takes WS server log data and logs it logWSServer
Instances
MonadWSLog AppM Source # | |
MonadWSLog m => MonadWSLog (ExceptT e m) Source # | |
MonadWSLog m => MonadWSLog (ReaderT r m) Source # | |
data WSQueueResponse Source #
Constructors
WSQueueResponse ByteString (Maybe WSEventInfo) (IO DiffTime) |
getRawWebSocketConnection :: WSConn a -> Connection Source #
sendMsgAndCloseConn :: WSConn a -> Word16 -> ByteString -> ServerMsg -> IO () Source #
Constructors
WSServer | |
Fields
|
createWSServer :: AuthMode -> AllowListStatus -> InlinedAllowlist -> CorsPolicy -> SQLGenCtx -> HashSet ExperimentalFeature -> NamingCase -> Logger Hasura -> STM (WSServer a) Source #
closeAllConnectionsWithReason :: WSServer a -> String -> ByteString -> (SecuritySensitiveUserConfig -> SecuritySensitiveUserConfig) -> IO () Source #
data AcceptWith a Source #
Constructors
AcceptWith !a !AcceptRequest !(WSConn a -> IO ()) !(WSConn a -> IO ()) |
type WSKeepAliveMessageAction a = WSConn a -> IO () Source #
These set of functions or message handlers is used by the server while communicating with the client. They are particularly useful for the case when the messages being sent to the client are different for each of the sub-protocol(s) supported by the server.
type WSOnErrorMessageAction a = WSConn a -> ConnErrMsg -> WSErrorMessage -> IO () Source #
Used for specific actions within the onConn
and onMessage
handlers
Constructors
WSActions | |
Fields
|
data WSErrorMessage Source #
Constructors
ClientMessageParseFailed | |
ConnInitFailed |
type OnConnH m a = WSId -> RequestHead -> IpAddress -> WSActions a -> m (Either RejectRequest (AcceptWith a)) Source #
type HasuraServerApp m = IpAddress -> PendingConnection -> m () Source #
aka generalized ServerApp
over m
, which takes an IPAddress
data WSHandlers m a Source #
NOTE: The types of _hOnConn
and _hOnMessage
were updated from OnConnH
and OnMessageH
because we needed to pass the subprotcol here to these methods to eventually get to OnConnH
and OnMessageH
.
Please see createServerApp
to get a better understanding of how these handlers are used.
Constructors
WSHandlers (WSId -> RequestHead -> IpAddress -> WSSubProtocol -> m (Either RejectRequest (AcceptWith a))) (WSConn a -> ByteString -> WSSubProtocol -> m ()) (OnCloseH m a) |
websocketConnectionReaper :: IO (AuthMode, AllowListStatus, CorsPolicy, SQLGenCtx, HashSet ExperimentalFeature, NamingCase) -> IO SchemaCache -> WSServer a -> IO Void Source #
The background thread responsible for closing all websocket connections when security sensitive user configuration changes. It checks for changes in the auth mode, allowlist, cors config, stringify num, dangerous boolean collapse, stringify big query numeric, experimental features and invalidates/closes all connections if there are any changes.
Arguments
:: (MonadIO m, MonadBaseControl IO m, Forall (Pure m), MonadWSLog m) | |
=> IO MetricsConfig | |
-> WSConnectionInitTimeout | |
-> WSServer a | |
-> PrometheusMetrics | |
-> WSHandlers m a | user provided handlers |
-> HasuraServerApp m | aka WS.ServerApp |