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

Simplex.Messaging.Agent.Store.AgentStore

Synopsis

Users

checkUser :: Connection -> UserId -> IO (Either StoreError ()) Source #

Queues and connections

createServer :: Connection -> SMPServer -> IO (Maybe KeyHash) Source #

Creates a new server, if it doesn't exist, and returns the passed key hash if it is different from stored.

createNewConn :: Connection -> TVar ChaChaDRG -> ConnData -> SConnectionMode c -> IO (Either StoreError ConnId) Source #

createSndConn :: Connection -> TVar ChaChaDRG -> ConnData -> NewSndQueue -> IO (Either StoreError (ConnId, SndQueue)) Source #

setConnDeleted :: Connection -> Bool -> ConnId -> IO () Source #

addProcessedRatchetKeyHash :: Connection -> ConnId -> ByteString -> IO () Source #

checkRatchetKeyHashExists :: Connection -> ConnId -> ByteString -> IO Bool Source #

deleteRatchetKeyHashesExpired :: Connection -> NominalDiffTime -> Int -> IO () Source #

deleteConn :: Connection -> Maybe NominalDiffTime -> ConnId -> IO (Maybe ConnId) Source #

Deletes connection, optionally checking for pending snd message deliveries; returns connection id if it was deleted

setLastBrokerTs :: Connection -> ConnId -> DBEntityId -> UTCTime -> IO () Source #

checkRcvMsgHashExists :: Connection -> ConnId -> ByteString -> IO Bool Source #

deleteRcvMsgHashesExpired :: Connection -> NominalDiffTime -> Int -> IO () Source #

deleteSndMsgsExpired :: Connection -> NominalDiffTime -> Int -> IO () Source #

getPendingCommandServers :: Connection -> [ConnId] -> IO [(ConnId, NonEmpty (Maybe SMPServer))] Source #

deleteExpiredNtfTokensToDelete :: Connection -> NominalDiffTime -> IO () Source #

getNtfRcvQueue :: Connection -> SMPQueueNtf -> IO (Either StoreError (ConnId, Int64, RcvNtfDhSecret, Maybe UTCTime)) Source #

setConnectionNtfs :: Connection -> ConnId -> Bool -> IO () Source #

File transfer

createRcvFile :: Connection -> TVar ChaChaDRG -> UserId -> FileDescription 'FRecipient -> FilePath -> FilePath -> CryptoFile -> Bool -> IO (Either StoreError RcvFileId) Source #

createRcvFileRedirect :: Connection -> TVar ChaChaDRG -> UserId -> FileDescription 'FRecipient -> FilePath -> FilePath -> CryptoFile -> FilePath -> CryptoFile -> Bool -> IO (Either StoreError RcvFileId) Source #

updateRcvChunkReplicaDelay :: Connection -> Int64 -> Int64 -> IO () Source #

updateRcvFileChunkReceived :: Connection -> Int64 -> Int64 -> FilePath -> IO () Source #

getNextRcvChunkToDownload :: Connection -> XFTPServer -> NominalDiffTime -> IO (Either StoreError (Maybe (RcvFileChunk, Bool, Maybe RcvFileId))) Source #

getNextRcvFileToDecrypt :: Connection -> NominalDiffTime -> IO (Either StoreError (Maybe RcvFile)) Source #

getRcvFilesExpired :: Connection -> NominalDiffTime -> IO [(DBRcvFileId, RcvFileId, FilePath)] Source #

createSndFile :: Connection -> TVar ChaChaDRG -> UserId -> CryptoFile -> Int -> FilePath -> SbKey -> CbNonce -> Maybe RedirectFileInfo -> IO (Either StoreError SndFileId) Source #

getNextSndFileToPrepare :: Connection -> NominalDiffTime -> IO (Either StoreError (Maybe SndFile)) Source #

getNextSndChunkToUpload :: Connection -> XFTPServer -> NominalDiffTime -> IO (Either StoreError (Maybe SndFileChunk)) Source #

updateSndChunkReplicaDelay :: Connection -> Int64 -> Int64 -> IO () Source #

getSndFilesExpired :: Connection -> NominalDiffTime -> IO [(DBSndFileId, SndFileId, Maybe FilePath)] Source #

resetServersStats :: Connection -> UTCTime -> IO () Source #

utilities

withConnection :: DBStore -> (Connection -> IO a) -> IO a Source #

withTransaction :: DBStore -> (Connection -> IO a) -> IO a Source #

withTransactionPriority :: DBStore -> Bool -> (Connection -> IO a) -> IO a Source #

firstRow :: (a -> b) -> e -> IO [a] -> IO (Either e b) Source #

firstRow' :: (a -> Either e b) -> e -> IO [a] -> IO (Either e b) Source #

maybeFirstRow :: Functor f => (a -> b) -> f [a] -> f (Maybe b) Source #

fromOnlyBI :: Only BoolInt -> Bool Source #

getWorkItem :: (Show i, AnyStoreError e) => String -> IO (Maybe i) -> (i -> IO (Either e a)) -> (i -> IO ()) -> IO (Either e (Maybe a)) Source #

getWorkItems :: (Show i, AnyStoreError e) => String -> IO [i] -> (i -> IO (Either e a)) -> (i -> IO ()) -> IO (Either e [Either e a]) Source #

Orphan instances

FromField ChunkReplicaId Source # 
Instance details

Methods

fromField :: FieldParser ChunkReplicaId #

FromField AConnectionMode Source # 
Instance details

Methods

fromField :: FieldParser AConnectionMode #

FromField AConnectionRequestUri Source # 
Instance details

Methods

fromField :: FieldParser AConnectionRequestUri #

FromField AgentMessageType Source # 
Instance details

Methods

fromField :: FieldParser AgentMessageType #

FromField ConnectionMode Source # 
Instance details

Methods

fromField :: FieldParser ConnectionMode #

FromField MsgIntegrity Source # 
Instance details

Methods

fromField :: FieldParser MsgIntegrity #

FromField MsgReceiptStatus Source # 
Instance details

Methods

fromField :: FieldParser MsgReceiptStatus #

FromField QueueStatus Source # 
Instance details

Methods

fromField :: FieldParser QueueStatus #

FromField SMPQueueUri Source # 
Instance details

Methods

fromField :: FieldParser SMPQueueUri #

FromField AgentCommand Source # 
Instance details

Methods

fromField :: FieldParser AgentCommand #

FromField AgentCommandTag Source # 
Instance details

Methods

fromField :: FieldParser AgentCommandTag #

FromField InternalId Source # 
Instance details

Methods

fromField :: FieldParser InternalId #

FromField InternalRcvId Source # 
Instance details

Methods

fromField :: FieldParser InternalRcvId #

FromField InternalSndId Source # 
Instance details

Methods

fromField :: FieldParser InternalSndId #

FromField MsgFlags Source # 
Instance details

Methods

fromField :: FieldParser MsgFlags #

FromField EntityId Source # 
Instance details

Methods

fromField :: FieldParser EntityId #

ToField ChunkReplicaId Source # 
Instance details

Methods

toField :: ChunkReplicaId -> SQLData #

ToField AConnectionRequestUri Source # 
Instance details

Methods

toField :: AConnectionRequestUri -> SQLData #

ToField AgentMessageType Source # 
Instance details

Methods

toField :: AgentMessageType -> SQLData #

ToField ConnectionMode Source # 
Instance details

Methods

toField :: ConnectionMode -> SQLData #

ToField MsgIntegrity Source # 
Instance details

Methods

toField :: MsgIntegrity -> SQLData #

ToField MsgReceiptStatus Source # 
Instance details

Methods

toField :: MsgReceiptStatus -> SQLData #

ToField QueueStatus Source # 
Instance details

Methods

toField :: QueueStatus -> SQLData #

ToField SMPQueueUri Source # 
Instance details

Methods

toField :: SMPQueueUri -> SQLData #

ToField AgentCommand Source # 
Instance details

Methods

toField :: AgentCommand -> SQLData #

ToField AgentCommandTag Source # 
Instance details

Methods

toField :: AgentCommandTag -> SQLData #

ToField InternalId Source # 
Instance details

Methods

toField :: InternalId -> SQLData #

ToField InternalRcvId Source # 
Instance details

Methods

toField :: InternalRcvId -> SQLData #

ToField InternalSndId Source # 
Instance details

Methods

toField :: InternalSndId -> SQLData #

ToField MsgFlags Source # 
Instance details

Methods

toField :: MsgFlags -> SQLData #

ToField EntityId Source # 
Instance details

Methods

toField :: EntityId -> SQLData #

FromField (NonEmpty TransportHost) Source # 
Instance details

Methods

fromField :: FieldParser (NonEmpty TransportHost) #

(Typeable c, ConnectionModeI c) => FromField (ConnectionRequestUri c) Source # 
Instance details

Methods

fromField :: FieldParser (ConnectionRequestUri c) #

FromField (Version v) Source # 
Instance details

Methods

fromField :: FieldParser (Version v) #

FromField [SMPQueueInfo] Source # 
Instance details

Methods

fromField :: FieldParser [SMPQueueInfo] #

ToField (NonEmpty TransportHost) Source # 
Instance details

Methods

toField :: NonEmpty TransportHost -> SQLData #

ConnectionModeI c => ToField (ConnectionRequestUri c) Source # 
Instance details

Methods

toField :: ConnectionRequestUri c -> SQLData #

ToField (SConnectionMode c) Source # 
Instance details

Methods

toField :: SConnectionMode c -> SQLData #

ToField (Version v) Source # 
Instance details

Methods

toField :: Version v -> SQLData #

ToField [SMPQueueInfo] Source # 
Instance details

Methods

toField :: [SMPQueueInfo] -> SQLData #

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k) => FromRow (a, b, c, d, e, f, g, h, i, j, k) Source # 
Instance details

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k)

(FromField a, FromField b, FromField c, FromField d, FromField e, FromField f, FromField g, FromField h, FromField i, FromField j, FromField k, FromField l) => FromRow (a, b, c, d, e, f, g, h, i, j, k, l) Source # 
Instance details

Methods

fromRow :: RowParser (a, b, c, d, e, f, g, h, i, j, k, l)

(ToField a, ToField b, ToField c, ToField d, ToField e, ToField f, ToField g, ToField h, ToField i, ToField j, ToField k, ToField l) => ToRow (a, b, c, d, e, f, g, h, i, j, k, l) Source # 
Instance details

Methods

toRow :: (a, b, c, d, e, f, g, h, i, j, k, l) -> [SQLData]