[websocket] add Subscription data

parent 245bc254
Pipeline #6083 failed with stages
in 6 minutes and 10 seconds
......@@ -53,7 +53,7 @@ server and client.
-- | Various update actions
data UpdateAction =
data Topic =
-- | Update given Servant Job (we currently send a request every
-- | second to get job status).
-- UpdateJob JobID
......@@ -63,7 +63,7 @@ data UpdateAction =
deriving (Eq, Show)
-- NOTE: I'm not sure if UserAction/UserSource is needed. I initially
-- TODO: I'm not sure if UserAction/UserSource is needed. I initially
-- created that to mark who initiated the action, but I think we don't
-- need it.
--
......@@ -78,7 +78,7 @@ data UserSource =
-- | Action possibly associated with user who triggered it (there can
-- be system actions as well)
data UserAction =
UserAction UserSource UpdateAction
UserAction UserSource Topic
deriving (Eq, Show)
......@@ -99,16 +99,27 @@ notificationsForUserAction :: UserAction -> m [ UserNotification ]
notificationsForUserAction = undefined
-- | Stores connection type associated with given user.
-- | A connected user can be either associated with his UserId or
-- don't have it, since he's not logged in (for public messages).
data ConnectedUser =
CUUser UserId
| CUPublic
deriving (Eq, Show)
-- | Stores connection type associated with given user, subscribed to
-- | a given topic.
--
-- We probably should set conn = Servant.API.WebSocket.Connection
data ConnectedUser conn =
ConnectedUser UserId conn
data Subscription conn =
Subscription ConnectedUser conn Topic
-- | Given a UserNotification and all connected users, send it to
-- interested ones. Possibly we could make this function as part of
-- a typeclass so that we can decide how to send the notification
-- | Given a UserNotification and all subscriptions, send it to all
-- matching ones. Possibly we could make this function as part of a
-- typeclass so that we can decide how to send the notification
-- based on whether we choose pure WebSockets, NATS or something
-- else.
sendNotification :: UserNotification -> [ ConnectedUser conn ] -> m ()
sendNotification :: UserNotification -> [ Subscription conn ] -> m ()
sendNotification = undefined
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment