simplexmq-6.5.0.16: SimpleXMQ message broker
Safe HaskellSafe-Inferred
LanguageHaskell2010

Simplex.Messaging.Agent.Store

Synopsis

Documentation

data StoredRcvQueue (q :: DBStored) Source #

A receive queue. SMP queue through which the agent receives messages from a sender.

Constructors

RcvQueue 

Fields

data ClientNtfCreds Source #

Constructors

ClientNtfCreds 

Fields

Instances

Instances details
Show ClientNtfCreds Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> ClientNtfCreds -> ShowS

show :: ClientNtfCreds -> String

showList :: [ClientNtfCreds] -> ShowS

data InvShortLink Source #

Instances

data StoredSndQueue (q :: DBStored) Source #

A send queue. SMP queue through which the agent sends messages to a recipient.

Constructors

SndQueue 

Fields

Instances

Instances details
SMPQueue SndQueue Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

SMPQueueRec SndQueue Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Show (StoredSndQueue q) Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> StoredSndQueue q -> ShowS

show :: StoredSndQueue q -> String

showList :: [StoredSndQueue q] -> ShowS

class SMPQueue q => SMPQueueRec q where Source #

Methods

qUserId :: q -> UserId Source #

qConnId :: q -> ConnId Source #

dbQId :: q -> Int64 Source #

qPrimary :: q -> Bool Source #

dbReplaceQId :: q -> Maybe Int64 Source #

data ConnType Source #

Type of a connection.

Constructors

CNew 
CRcv 
CSnd 
CDuplex 
CContact 

Instances

Instances details
Show ConnType Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> ConnType -> ShowS

show :: ConnType -> String

showList :: [ConnType] -> ShowS

Eq ConnType Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

(==) :: ConnType -> ConnType -> Bool

(/=) :: ConnType -> ConnType -> Bool

TestEquality SConnType Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

testEquality :: forall (a :: k) (b :: k). SConnType a -> SConnType b -> Maybe (a :~: b)

data Connection' (d :: ConnType) rq sq where Source #

Connection of a specific type.

  • RcvConnection is a connection that only has a receive queue set up, typically created by a recipient initiating a duplex connection.
  • SndConnection is a connection that only has a send queue set up, typically created by a sender joining a duplex connection through a recipient's invitation.
  • DuplexConnection is a connection that has both receive and send queues set up, typically created by upgrading a receive or a send connection with a missing queue.

Constructors

NewConnection :: ConnData -> Connection' CNew rq sq 
RcvConnection :: ConnData -> rq -> Connection' CRcv rq sq 
SndConnection :: ConnData -> sq -> Connection' CSnd rq sq 
DuplexConnection :: ConnData -> NonEmpty rq -> NonEmpty sq -> Connection' CDuplex rq sq 
ContactConnection :: ConnData -> rq -> Connection' CContact rq sq 

Instances

Instances details
(Show rq, Show sq) => Show (Connection' d rq sq) Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> Connection' d rq sq -> ShowS

show :: Connection' d rq sq -> String

showList :: [Connection' d rq sq] -> ShowS

data SConnType :: ConnType -> Type where Source #

Instances

Instances details
TestEquality SConnType Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

testEquality :: forall (a :: k) (b :: k). SConnType a -> SConnType b -> Maybe (a :~: b)

Show (SConnType d) Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> SConnType d -> ShowS

show :: SConnType d -> String

showList :: [SConnType d] -> ShowS

data SomeConn' rq sq Source #

Connection of an unknown type. Used to refer to an arbitrary connection when retrieving from store.

Constructors

forall d. SomeConn (SConnType d) (Connection' d rq sq) 

Instances

Instances details
(Show rq, Show sq) => Show (SomeConn' rq sq) Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> SomeConn' rq sq -> ShowS

show :: SomeConn' rq sq -> String

showList :: [SomeConn' rq sq] -> ShowS

data ConnData Source #

Instances

Instances details
Show ConnData Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> ConnData -> ShowS

show :: ConnData -> String

showList :: [ConnData] -> ShowS

Eq ConnData Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

(==) :: ConnData -> ConnData -> Bool

(/=) :: ConnData -> ConnData -> Bool

type NoticeId = Int64 Source #

data AgentCmdType Source #

Constructors

ACClient 
ACInternal 

Instances

Instances details
StrEncoding AgentCmdType Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

strEncode :: AgentCmdType -> ByteString Source #

strDecode :: ByteString -> Either String AgentCmdType Source #

strP :: Parser AgentCmdType Source #

data AgentCommand Source #

Instances

Instances details
StrEncoding AgentCommand Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

strEncode :: AgentCommand -> ByteString Source #

strDecode :: ByteString -> Either String AgentCommand Source #

strP :: Parser AgentCommand Source #

FromField AgentCommand Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

fromField :: FieldParser AgentCommand #

ToField AgentCommand Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

toField :: AgentCommand -> SQLData #

data AgentCommandTag Source #

Instances

Instances details
Show AgentCommandTag Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> AgentCommandTag -> ShowS

show :: AgentCommandTag -> String

showList :: [AgentCommandTag] -> ShowS

StrEncoding AgentCommandTag Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

strEncode :: AgentCommandTag -> ByteString Source #

strDecode :: ByteString -> Either String AgentCommandTag Source #

strP :: Parser AgentCommandTag Source #

FromField AgentCommandTag Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

fromField :: FieldParser AgentCommandTag #

ToField AgentCommandTag Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

toField :: AgentCommandTag -> SQLData #

type PrevExternalSndId = Int64 Source #

Corresponds to last_external_snd_msg_id in connections table

type PrevRcvMsgHash = MsgHash Source #

Corresponds to last_rcv_msg_hash in connections table

type PrevSndMsgHash = MsgHash Source #

Corresponds to last_snd_msg_hash in connections table

data SndMsgPrepData Source #

Constructors

SndMsgPrepData 

Fields

Instances

Instances details
Show SndMsgPrepData Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> SndMsgPrepData -> ShowS

show :: SndMsgPrepData -> String

showList :: [SndMsgPrepData] -> ShowS

data PendingMsgPrepData Source #

Instances

Instances details
Show PendingMsgPrepData Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> PendingMsgPrepData -> ShowS

show :: PendingMsgPrepData -> String

showList :: [PendingMsgPrepData] -> ShowS

newtype InternalRcvId Source #

Constructors

InternalRcvId 

Fields

Instances

Instances details
Show InternalRcvId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> InternalRcvId -> ShowS

show :: InternalRcvId -> String

showList :: [InternalRcvId] -> ShowS

Eq InternalRcvId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

FromField InternalRcvId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

fromField :: FieldParser InternalRcvId #

ToField InternalRcvId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

toField :: InternalRcvId -> SQLData #

type ExternalSndId = Int64 Source #

type ExternalSndTs = UTCTime Source #

type BrokerTs = UTCTime Source #

newtype InternalSndId Source #

Constructors

InternalSndId 

Fields

Instances

Instances details
Show InternalSndId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> InternalSndId -> ShowS

show :: InternalSndId -> String

showList :: [InternalSndId] -> ShowS

Eq InternalSndId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

FromField InternalSndId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

fromField :: FieldParser InternalSndId #

ToField InternalSndId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

toField :: InternalSndId -> SQLData #

data MsgBase Source #

Base message data independent of direction.

Constructors

MsgBase 

Fields

  • connId :: ConnId
     
  • internalId :: InternalId

    Monotonically increasing id of a message per connection, internal to the agent. Internal Id preserves ordering between both received and sent messages, and is needed to track the order of the conversation (which can be different for the sender / receiver) and address messages in commands. External [sender] Id cannot be used for this purpose due to a possibility of implementation errors in different agents.

  • internalTs :: InternalTs
     
  • msgBody :: MsgBody
     
  • internalHash :: MsgHash

    Hash of the message as computed by agent.

Instances

Instances details
Show MsgBase Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> MsgBase -> ShowS

show :: MsgBase -> String

showList :: [MsgBase] -> ShowS

Eq MsgBase Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

(==) :: MsgBase -> MsgBase -> Bool

(/=) :: MsgBase -> MsgBase -> Bool

newtype InternalId Source #

Constructors

InternalId 

Fields

Instances

Instances details
Show InternalId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> InternalId -> ShowS

show :: InternalId -> String

showList :: [InternalId] -> ShowS

Eq InternalId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

(==) :: InternalId -> InternalId -> Bool

(/=) :: InternalId -> InternalId -> Bool

StrEncoding InternalId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

strEncode :: InternalId -> ByteString Source #

strDecode :: ByteString -> Either String InternalId Source #

strP :: Parser InternalId Source #

FromField InternalId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

fromField :: FieldParser InternalId #

ToField InternalId Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store.AgentStore

Methods

toField :: InternalId -> SQLData #

type InternalTs = UTCTime Source #

type AsyncCmdId = Int64 Source #

data StoreError Source #

Agent store error.

Constructors

SEInternal ByteString

IO exceptions in store actions.

SEDatabaseBusy ByteString

Database busy

SEUniqueID

Failed to generate unique random ID

SEUserNotFound

User ID not found

SEConnNotFound

Connection not found (or both queues absent).

SEServerNotFound

Server not found.

SEConnDuplicate

Connection already used.

SESndQueueExists

Confirmed snd queue already exists.

SEBadConnType String ConnType

Wrong connection type, e.g. "send" connection when "receive" or "duplex" is expected, or vice versa. upgradeRcvConnToDuplex and upgradeSndConnToDuplex do not allow duplex connections - they would also return this error.

SEConfirmationNotFound

Confirmation not found.

SEInvitationNotFound String InvitationId

Invitation not found

SEMsgNotFound String

Message not found

SECmdNotFound

Command not found

SEBadQueueStatus

Currently not used. The intention was to pass current expected queue status in methods, as we always know what it should be at any stage of the protocol, and in case it does not match use this error.

SERatchetNotFound

connection does not have associated double-ratchet state

SEX3dhKeysNotFound

connection does not have associated x3dh keys

SEAgentError AgentErrorType

Used to wrap agent errors inside store operations to avoid race conditions

SEXFTPServerNotFound

XFTP Server not found.

SEFileNotFound

XFTP File not found.

SEDeletedSndChunkReplicaNotFound

XFTP Deleted snd chunk replica not found.

SEWorkItemError

Error when reading work item that suspends worker - do not use!

Fields

SEServersStatsNotFound

Servers stats not found.

Instances

Instances details
Exception StoreError Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

toException :: StoreError -> SomeException

fromException :: SomeException -> Maybe StoreError

displayException :: StoreError -> String

Show StoreError Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

showsPrec :: Int -> StoreError -> ShowS

show :: StoreError -> String

showList :: [StoreError] -> ShowS

Eq StoreError Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

(==) :: StoreError -> StoreError -> Bool

(/=) :: StoreError -> StoreError -> Bool

AnyStoreError StoreError Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

AnyError StoreError Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

Methods

fromSomeException :: SomeException -> StoreError Source #

class (Show e, AnyError e) => AnyStoreError e where Source #

Methods

isWorkItemError :: e -> Bool Source #

mkWorkItemError :: String -> e Source #

Instances

Instances details
AnyStoreError StoreError Source # 
Instance details

Defined in Simplex.Messaging.Agent.Store

findQ :: SMPQueue q => (SMPServer, QueueId) -> NonEmpty q -> Maybe q Source #

removeQ :: SMPQueue q => (SMPServer, QueueId) -> NonEmpty q -> Maybe (q, [q]) Source #

removeQP :: (q -> Bool) -> NonEmpty q -> Maybe (q, [q]) Source #

findRQ :: (SMPServer, SenderId) -> NonEmpty RcvQueue -> Maybe RcvQueue Source #

switchingRQ :: NonEmpty RcvQueue -> Maybe RcvQueue Source #

updatedQs :: SMPQueueRec q => q -> NonEmpty q -> NonEmpty q Source #