{-# LANGUAGE FunctionalDependencies #-}
module Simplex.Messaging.Server.MsgStore where
import Data.Time.Clock
import Numeric.Natural
import Simplex.Messaging.Protocol (Encoded, MsgBody, RecipientId)
data Message = Message
{ Message -> Encoded
msgId :: Encoded,
Message -> UTCTime
ts :: UTCTime,
Message -> Encoded
msgBody :: MsgBody
}
class MonadMsgStore s q m | s -> q where
getMsgQueue :: s -> RecipientId -> Natural -> m q
delMsgQueue :: s -> RecipientId -> m ()
class MonadMsgQueue q m where
isFull :: q -> m Bool
writeMsg :: q -> Message -> m ()
tryPeekMsg :: q -> m (Maybe Message)
peekMsg :: q -> m Message
tryDelPeekMsg :: q -> m (Maybe Message)