mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-08-05 15:20:20 +00:00
agent store: move SQLite Types -> Util (#30)
This commit is contained in:
@@ -21,7 +21,7 @@ import Data.Text.Encoding
|
||||
import Simplex.Messaging.Agent.Client
|
||||
import Simplex.Messaging.Agent.Env.SQLite
|
||||
import Simplex.Messaging.Agent.Store
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Types
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Util (SQLiteStore)
|
||||
import Simplex.Messaging.Agent.Store.Types
|
||||
import Simplex.Messaging.Agent.Transmission
|
||||
import Simplex.Messaging.Client (SMPServerTransmission)
|
||||
|
||||
@@ -10,7 +10,7 @@ import Crypto.Random
|
||||
import Network.Socket
|
||||
import Numeric.Natural
|
||||
import Simplex.Messaging.Agent.Store.SQLite
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Types
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Util (SQLiteStore)
|
||||
import Simplex.Messaging.Client
|
||||
import UnliftIO.STM
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import Data.Maybe
|
||||
import qualified Database.SQLite.Simple as DB
|
||||
import Simplex.Messaging.Agent.Store
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Schema
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Types
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Util
|
||||
import Simplex.Messaging.Agent.Store.Types
|
||||
import Simplex.Messaging.Agent.Transmission
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
{-# LANGUAGE FlexibleContexts #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
{-# LANGUAGE UndecidableInstances #-}
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Simplex.Messaging.Agent.Store.SQLite.Types where
|
||||
|
||||
import Data.Int (Int64)
|
||||
import qualified Database.SQLite.Simple as DB
|
||||
import UnliftIO.STM
|
||||
|
||||
data SQLiteStore = SQLiteStore
|
||||
{ dbFilename :: String,
|
||||
conn :: DB.Connection,
|
||||
serversLock :: TMVar (),
|
||||
rcvQueuesLock :: TMVar (),
|
||||
sndQueuesLock :: TMVar (),
|
||||
connectionsLock :: TMVar (),
|
||||
messagesLock :: TMVar ()
|
||||
}
|
||||
|
||||
type QueueRowId = Int64
|
||||
|
||||
type ConnectionRowId = Int64
|
||||
@@ -31,7 +31,6 @@ import Database.SQLite.Simple.QQ (sql)
|
||||
import Database.SQLite.Simple.ToField
|
||||
import Network.Socket
|
||||
import Simplex.Messaging.Agent.Store
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Types
|
||||
import Simplex.Messaging.Agent.Store.Types
|
||||
import Simplex.Messaging.Agent.Transmission
|
||||
import Simplex.Messaging.Protocol as SMP
|
||||
@@ -40,6 +39,20 @@ import Text.Read
|
||||
import qualified UnliftIO.Exception as E
|
||||
import UnliftIO.STM
|
||||
|
||||
data SQLiteStore = SQLiteStore
|
||||
{ dbFilename :: String,
|
||||
conn :: DB.Connection,
|
||||
serversLock :: TMVar (),
|
||||
rcvQueuesLock :: TMVar (),
|
||||
sndQueuesLock :: TMVar (),
|
||||
connectionsLock :: TMVar (),
|
||||
messagesLock :: TMVar ()
|
||||
}
|
||||
|
||||
type QueueRowId = Int64
|
||||
|
||||
type ConnectionRowId = Int64
|
||||
|
||||
addRcvQueueQuery :: Query
|
||||
addRcvQueueQuery =
|
||||
[sql|
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
module AgentTests where
|
||||
|
||||
import AgentTests.SQLite
|
||||
import AgentTests.SQLiteTests (storeTests)
|
||||
import Data.ByteString.Char8 (ByteString)
|
||||
import qualified Data.ByteString.Char8 as B
|
||||
import SMPAgentClient
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
{-# LANGUAGE DuplicateRecordFields #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module AgentTests.SQLite where
|
||||
module AgentTests.SQLiteTests where
|
||||
|
||||
import Control.Monad.Except
|
||||
import Data.Word (Word32)
|
||||
import qualified Database.SQLite.Simple as DB
|
||||
import Simplex.Messaging.Agent.Store
|
||||
import Simplex.Messaging.Agent.Store.SQLite
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Types
|
||||
import Simplex.Messaging.Agent.Store.SQLite.Util (SQLiteStore, conn, dbFilename)
|
||||
import Simplex.Messaging.Agent.Store.Types
|
||||
import Simplex.Messaging.Agent.Transmission
|
||||
import System.Random
|
||||
Reference in New Issue
Block a user