mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-09-01 18:08:36 +00:00
* refactor/optimize server queue/message store * change fst to pattern match * server store - wrap QueueRec into TVar
29 lines
1.0 KiB
Haskell
29 lines
1.0 KiB
Haskell
{-# LANGUAGE DataKinds #-}
|
|
{-# LANGUAGE KindSignatures #-}
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
module Simplex.Messaging.Server.QueueStore where
|
|
|
|
import Simplex.Messaging.Protocol
|
|
|
|
data QueueRec = QueueRec
|
|
{ recipientId :: RecipientId,
|
|
recipientKey :: RcvPublicVerifyKey,
|
|
rcvDhSecret :: RcvDhSecret,
|
|
senderId :: SenderId,
|
|
senderKey :: Maybe SndPublicVerifyKey,
|
|
notifier :: Maybe (NotifierId, NtfPublicVerifyKey),
|
|
status :: QueueStatus
|
|
}
|
|
deriving (Eq, Show)
|
|
|
|
data QueueStatus = QueueActive | QueueOff deriving (Eq, Show)
|
|
|
|
class MonadQueueStore s m where
|
|
addQueue :: s -> QueueRec -> m (Either ErrorType ())
|
|
getQueue :: s -> SParty p -> QueueId -> m (Either ErrorType QueueRec)
|
|
secureQueue :: s -> RecipientId -> SndPublicVerifyKey -> m (Either ErrorType QueueRec)
|
|
addQueueNotifier :: s -> RecipientId -> NotifierId -> NtfPublicVerifyKey -> m (Either ErrorType QueueRec)
|
|
suspendQueue :: s -> RecipientId -> m (Either ErrorType ())
|
|
deleteQueue :: s -> RecipientId -> m (Either ErrorType ())
|