mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-04-09 19:06:16 +00:00
23 lines
611 B
Haskell
23 lines
611 B
Haskell
{-# LANGUAGE FunctionalDependencies #-}
|
|
|
|
module MsgStore where
|
|
|
|
import Data.Time.Clock
|
|
import Transmission
|
|
|
|
data Message = Message
|
|
{ msgId :: Encoded,
|
|
ts :: UTCTime,
|
|
msgBody :: MsgBody
|
|
}
|
|
|
|
class MonadMsgStore s q m | s -> q where
|
|
getMsgQueue :: s -> RecipientId -> m q
|
|
delMsgQueue :: s -> RecipientId -> m ()
|
|
|
|
class MonadMsgQueue q m where
|
|
writeMsg :: q -> Message -> m () -- non blocking
|
|
tryPeekMsg :: q -> m (Maybe Message) -- non blocking
|
|
peekMsg :: q -> m Message -- blocking
|
|
tryDelPeekMsg :: q -> m (Maybe Message) -- atomic delete (== read) last and peek next message, if available
|