mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-10-22 13:12:01 +00:00
test: agent SQLite createRcvConnection
This commit is contained in:
1 parent
f8e25189db
commit
5d2e77f41d
7 files changed
+75
-15
No files matched your search
@@ -25,6 +25,7 @@ data ReceiveQueue = ReceiveQueue
|
||||
status :: QueueStatus,
|
||||
ackMode :: AckMode -- whether acknowledgement will be sent (via SendQueue if present)
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
data SendQueue = SendQueue
|
||||
{ server :: SMPServer,
|
||||
@@ -35,14 +36,19 @@ data SendQueue = SendQueue
|
||||
status :: QueueStatus,
|
||||
ackMode :: AckMode -- whether acknowledgement is expected (via ReceiveQueue if present)
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
||||
data ConnType = CSend | CReceive | CDuplex
|
||||
data ConnType = CSend | CReceive | CDuplex deriving (Eq, Show)
|
||||
|
||||
data Connection (d :: ConnType) where
|
||||
ReceiveConnection :: ConnAlias -> ReceiveQueue -> Connection CReceive
|
||||
SendConnection :: ConnAlias -> SendQueue -> Connection CSend
|
||||
DuplexConnection :: ConnAlias -> ReceiveQueue -> SendQueue -> Connection CDuplex
|
||||
|
||||
deriving instance Show (Connection d)
|
||||
|
||||
deriving instance Eq (Connection d)
|
||||
|
||||
data SConnType :: ConnType -> Type where
|
||||
SCReceive :: SConnType CReceive
|
||||
SCSend :: SConnType CSend
|
||||
@@ -93,3 +99,4 @@ data StoreError
|
||||
| SEMsgNotFound
|
||||
| SEBadConnType ConnType
|
||||
| SEBadQueueStatus
|
||||
deriving (Eq, Show)
|
||||
@@ -107,8 +107,8 @@ upsertServer SQLiteStore {conn} srv@SMPServer {host, port} = liftIO $ do
|
||||
conn
|
||||
[s|
|
||||
INSERT INTO servers (host, port, key_hash) VALUES (?, ?, ?)
|
||||
ON CONFLICT (host_address, port) DO UPDATE SET
|
||||
host_address=excluded.host_address,
|
||||
ON CONFLICT (host, port) DO UPDATE SET
|
||||
host=excluded.host,
|
||||
port=excluded.port,
|
||||
key_hash=excluded.key_hash;
|
||||
|]
|
||||
|
||||
@@ -101,7 +101,7 @@ data SMPServer = SMPServer
|
||||
port :: Maybe ServiceName,
|
||||
keyHash :: Maybe KeyHash
|
||||
}
|
||||
deriving (Show)
|
||||
deriving (Eq, Show)
|
||||
|
||||
type KeyHash = Encoded
|
||||
|
||||
@@ -109,9 +109,9 @@ type ConnAlias = ByteString
|
||||
|
||||
type OtherPartyId = Encoded
|
||||
|
||||
data Mode = On | Off deriving (Show, Read)
|
||||
data Mode = On | Off deriving (Eq, Show, Read)
|
||||
|
||||
newtype AckMode = AckMode Mode deriving (Show)
|
||||
newtype AckMode = AckMode Mode deriving (Eq, Show)
|
||||
|
||||
newtype SubMode = SubMode Mode deriving (Show)
|
||||
|
||||
@@ -125,7 +125,7 @@ type VerificationKey = PublicKey
|
||||
data QueueDirection = SND | RCV deriving (Show)
|
||||
|
||||
data QueueStatus = New | Confirmed | Secured | Active | Disabled
|
||||
deriving (Show, Read)
|
||||
deriving (Eq, Show, Read)
|
||||
|
||||
type AgentMsgId = Int
|
||||
|
||||
|
||||
Reference in new issue
Block a user