Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype WSId = WSId {
- unWSId :: UUID
- mkUnsafeWSId :: UUID -> WSId
- data MessageDetails = MessageDetails {}
- data WSEvent
- data WSEventInfo = WSEventInfo {}
- data WSLog = WSLog {
- _wslWebsocketId :: !WSId
- _wslEvent :: !WSEvent
- _wslMetadata :: !(Maybe WSEventInfo)
- class Monad m => MonadWSLog m where
- data WSQueueResponse = WSQueueResponse {
- _wsqrMessage :: !ByteString
- _wsqrEventInfo :: !(Maybe WSEventInfo)
- data WSConn a = WSConn {
- _wcConnId :: !WSId
- _wcLogger :: !(Logger Hasura)
- _wcConnRaw :: !Connection
- _wcSendQ :: !(TQueue WSQueueResponse)
- _wcExtraData :: !a
- getRawWebSocketConnection :: WSConn a -> Connection
- getData :: WSConn a -> a
- getWSId :: WSConn a -> WSId
- closeConn :: WSConn a -> ByteString -> IO ()
- forceConnReconnect :: MonadIO m => WSConn a -> ByteString -> m ()
- closeConnWithCode :: WSConn a -> Word16 -> ByteString -> IO ()
- sendMsg :: WSConn a -> WSQueueResponse -> IO ()
- type ConnMap a = Map WSId (WSConn a)
- data ServerStatus a
- = AcceptingConns !(ConnMap a)
- | ShuttingDown
- data WSServer a = WSServer {
- _wssLogger :: !(Logger Hasura)
- _wssStatus :: !(TVar (ServerStatus a))
- createWSServer :: Logger Hasura -> STM (WSServer a)
- closeAllWith :: (ByteString -> WSConn a -> IO ()) -> ByteString -> [(WSId, WSConn a)] -> IO ()
- flushConnMap :: TVar (ServerStatus a) -> STM [(WSId, WSConn a)]
- data AcceptWith a = AcceptWith {
- _awData :: !a
- _awReq :: !AcceptRequest
- _awKeepAlive :: !(WSConn a -> IO ())
- _awOnJwtExpiry :: !(WSConn a -> IO ())
- type WSKeepAliveMessageAction a = WSConn a -> IO ()
- type WSPostExecErrMessageAction a = WSConn a -> OperationId -> GQExecError -> IO ()
- type WSOnErrorMessageAction a = WSConn a -> ConnErrMsg -> Maybe String -> IO ()
- type WSCloseConnAction a = WSConn a -> OperationId -> String -> IO ()
- data WSActions a = WSActions {
- _wsaPostExecErrMessageAction :: !(WSPostExecErrMessageAction a)
- _wsaOnErrorMessageAction :: !(WSOnErrorMessageAction a)
- _wsaConnectionCloseAction :: !(WSCloseConnAction a)
- _wsaKeepAliveAction :: !(WSKeepAliveMessageAction a)
- _wsaGetDataMessageType :: !(DataMsg -> ServerMsg)
- _wsaAcceptRequest :: !AcceptRequest
- _wsaErrorMsgFormat :: !([Value] -> Value)
- onClientMessageParseErrorText :: Maybe String
- onConnInitErrorText :: Maybe String
- type OnConnH m a = WSId -> RequestHead -> IpAddress -> WSActions a -> m (Either RejectRequest (AcceptWith a))
- type OnCloseH m a = WSConn a -> m ()
- type HasuraServerApp m = IpAddress -> PendingConnection -> m ()
- data WSHandlers m a = WSHandlers {
- _hOnConn :: WSId -> RequestHead -> IpAddress -> WSSubProtocol -> m (Either RejectRequest (AcceptWith a))
- _hOnMessage :: WSConn a -> ByteString -> WSSubProtocol -> m ()
- _hOnClose :: OnCloseH m a
- createServerApp :: (MonadIO m, MonadBaseControl IO m, Forall (Pure m), MonadWSLog m) => WSConnectionInitTimeout -> WSServer a -> WSHandlers m a -> HasuraServerApp m
- shutdown :: WSServer a -> IO ()
Documentation
Instances
Eq WSId Source # | |
Show WSId Source # | |
Hashable WSId Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server | |
ToJSON WSId Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server |
mkUnsafeWSId :: UUID -> WSId Source #
data MessageDetails Source #
Websocket message and other details
Instances
Show MessageDetails Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server showsPrec :: Int -> MessageDetails -> ShowS # show :: MessageDetails -> String # showList :: [MessageDetails] -> ShowS # | |
ToJSON MessageDetails Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server toJSON :: MessageDetails -> Value toEncoding :: MessageDetails -> Encoding toJSONList :: [MessageDetails] -> Value toEncodingList :: [MessageDetails] -> Encoding |
EConnectionRequest | |
EAccepted | |
ERejected | |
EMessageReceived !MessageDetails | |
EMessageSent !MessageDetails | |
EJwtExpired | |
ECloseReceived | |
ECloseSent !SerializableBlob | |
EClosed |
Instances
Show WSEvent Source # | |
ToJSON WSEvent Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server toEncoding :: WSEvent -> Encoding toJSONList :: [WSEvent] -> Value toEncodingList :: [WSEvent] -> Encoding |
data WSEventInfo Source #
Instances
Eq WSEventInfo Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server (==) :: WSEventInfo -> WSEventInfo -> Bool # (/=) :: WSEventInfo -> WSEventInfo -> Bool # | |
Show WSEventInfo Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server showsPrec :: Int -> WSEventInfo -> ShowS # show :: WSEventInfo -> String # showList :: [WSEventInfo] -> ShowS # | |
ToJSON WSEventInfo Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server toJSON :: WSEventInfo -> Value toEncoding :: WSEventInfo -> Encoding toJSONList :: [WSEventInfo] -> Value toEncodingList :: [WSEventInfo] -> Encoding |
WSLog | |
|
Instances
Show WSLog Source # | |
ToJSON WSLog Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server | |
ToEngineLog WSLog Hasura Source # | |
Defined in Hasura.GraphQL.Transport.WebSocket.Server toEngineLog :: WSLog -> (LogLevel, EngineLogType Hasura, Value) Source # |
class Monad m => MonadWSLog m where Source #
Instances
MonadIO m => MonadWSLog (PGMetadataStorageAppT m) Source # | |
Defined in Hasura.App | |
MonadWSLog m => MonadWSLog (ExceptT e m) Source # | |
MonadWSLog m => MonadWSLog (ReaderT r m) Source # | |
data WSQueueResponse Source #
WSQueueResponse | |
|
WSConn | |
|
getRawWebSocketConnection :: WSConn a -> Connection Source #
forceConnReconnect :: MonadIO m => WSConn a -> ByteString -> m () Source #
Closes a connection with code 1012, which means "Server is restarting" good clients will implement a retry logic with a backoff of a few seconds
closeConnWithCode :: WSConn a -> Word16 -> ByteString -> IO () Source #
data ServerStatus a Source #
WSServer | |
|
closeAllWith :: (ByteString -> WSConn a -> IO ()) -> ByteString -> [(WSId, WSConn a)] -> IO () Source #
flushConnMap :: TVar (ServerStatus a) -> STM [(WSId, WSConn a)] Source #
Resets the current connections map to an empty one if the server is running and returns the list of connections that were in the map before flushing it.
data AcceptWith a Source #
AcceptWith | |
|
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 WSPostExecErrMessageAction a = WSConn a -> OperationId -> GQExecError -> IO () Source #
type WSOnErrorMessageAction a = WSConn a -> ConnErrMsg -> Maybe String -> IO () Source #
type WSCloseConnAction a = WSConn a -> OperationId -> String -> IO () Source #
Used for specific actions within the onConn
and onMessage
handlers
WSActions | |
|
onClientMessageParseErrorText :: Maybe String Source #
to be used with WSOnErrorMessageAction
onConnInitErrorText :: Maybe String Source #
to be used with WSOnErrorMessageAction
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.
WSHandlers | |
|
:: (MonadIO m, MonadBaseControl IO m, Forall (Pure m), MonadWSLog m) | |
=> WSConnectionInitTimeout | |
-> WSServer a | |
-> WSHandlers m a | user provided handlers |
-> HasuraServerApp m | aka WS.ServerApp |