core: remove connection pool (#738)
* core: remove connection pool * remove local ref from cabal.project * update simplexmq * log test * fix test
This commit is contained in:
parent
1f1ed3f3dd
commit
c62d99ab97
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,3 +42,4 @@ stack.yaml.lock
|
|||||||
|
|
||||||
# Temporary test files
|
# Temporary test files
|
||||||
tests/tmp
|
tests/tmp
|
||||||
|
logs/
|
||||||
|
@ -5,7 +5,7 @@ constraints: zip +disable-bzip2 +disable-zstd
|
|||||||
source-repository-package
|
source-repository-package
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/simplex-chat/simplexmq.git
|
location: https://github.com/simplex-chat/simplexmq.git
|
||||||
tag: c1348aa54fba292d34339d6b111572cb1c74b546
|
tag: 5f94240ed420c42c725810b72b7f512ab320a98f
|
||||||
|
|
||||||
source-repository-package
|
source-repository-package
|
||||||
type: git
|
type: git
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"https://github.com/simplex-chat/simplexmq.git"."c1348aa54fba292d34339d6b111572cb1c74b546" = "103hw1h1agy42krf11d98bv3c1w0q0wi2z7r2ll0gmp5xv1r4rf0";
|
"https://github.com/simplex-chat/simplexmq.git"."5f94240ed420c42c725810b72b7f512ab320a98f" = "194zdljlm85w97zql35ikswwpv0r5j6651bn6xqa6z7wmb5dvsxp";
|
||||||
"https://github.com/simplex-chat/aeson.git"."3eb66f9a68f103b5f1489382aad89f5712a64db7" = "0kilkx59fl6c3qy3kjczqvm8c3f4n3p0bdk9biyflf51ljnzp4yp";
|
"https://github.com/simplex-chat/aeson.git"."3eb66f9a68f103b5f1489382aad89f5712a64db7" = "0kilkx59fl6c3qy3kjczqvm8c3f4n3p0bdk9biyflf51ljnzp4yp";
|
||||||
"https://github.com/simplex-chat/haskell-terminal.git"."f708b00009b54890172068f168bf98508ffcd495" = "0zmq7lmfsk8m340g47g5963yba7i88n4afa6z93sg9px5jv1mijj";
|
"https://github.com/simplex-chat/haskell-terminal.git"."f708b00009b54890172068f168bf98508ffcd495" = "0zmq7lmfsk8m340g47g5963yba7i88n4afa6z93sg9px5jv1mijj";
|
||||||
"https://github.com/zw3rk/android-support.git"."3c3a5ab0b8b137a072c98d3d0937cbdc96918ddb" = "1r6jyxbim3dsvrmakqfyxbd6ms6miaghpbwyl0sr6dzwpgaprz97";
|
"https://github.com/zw3rk/android-support.git"."3c3a5ab0b8b137a072c98d3d0937cbdc96918ddb" = "1r6jyxbim3dsvrmakqfyxbd6ms6miaghpbwyl0sr6dzwpgaprz97";
|
||||||
|
@ -82,10 +82,8 @@ defaultChatConfig =
|
|||||||
defaultAgentConfig
|
defaultAgentConfig
|
||||||
{ tcpPort = undefined, -- agent does not listen to TCP
|
{ tcpPort = undefined, -- agent does not listen to TCP
|
||||||
dbFile = "simplex_v1",
|
dbFile = "simplex_v1",
|
||||||
dbPoolSize = 1,
|
|
||||||
yesToMigrations = False
|
yesToMigrations = False
|
||||||
},
|
},
|
||||||
dbPoolSize = 1,
|
|
||||||
yesToMigrations = False,
|
yesToMigrations = False,
|
||||||
defaultServers = InitialAgentServers {smp = _defaultSMPServers, ntf = _defaultNtfServers},
|
defaultServers = InitialAgentServers {smp = _defaultSMPServers, ntf = _defaultNtfServers},
|
||||||
tbqSize = 64,
|
tbqSize = 64,
|
||||||
|
@ -56,7 +56,6 @@ updateStr = "To update run: curl -o- https://raw.githubusercontent.com/simplex-c
|
|||||||
|
|
||||||
data ChatConfig = ChatConfig
|
data ChatConfig = ChatConfig
|
||||||
{ agentConfig :: AgentConfig,
|
{ agentConfig :: AgentConfig,
|
||||||
dbPoolSize :: Int,
|
|
||||||
yesToMigrations :: Bool,
|
yesToMigrations :: Bool,
|
||||||
defaultServers :: InitialAgentServers,
|
defaultServers :: InitialAgentServers,
|
||||||
tbqSize :: Natural,
|
tbqSize :: Natural,
|
||||||
|
@ -15,7 +15,7 @@ import Simplex.Chat.Types
|
|||||||
import UnliftIO.Async
|
import UnliftIO.Async
|
||||||
|
|
||||||
simplexChatCore :: ChatConfig -> ChatOpts -> Maybe (Notification -> IO ()) -> (User -> ChatController -> IO ()) -> IO ()
|
simplexChatCore :: ChatConfig -> ChatOpts -> Maybe (Notification -> IO ()) -> (User -> ChatController -> IO ()) -> IO ()
|
||||||
simplexChatCore cfg@ChatConfig {dbPoolSize, yesToMigrations} opts sendToast chat
|
simplexChatCore cfg@ChatConfig {yesToMigrations} opts sendToast chat
|
||||||
| logAgent opts = do
|
| logAgent opts = do
|
||||||
setLogLevel LogInfo -- LogError
|
setLogLevel LogInfo -- LogError
|
||||||
withGlobalLogging logCfg initRun
|
withGlobalLogging logCfg initRun
|
||||||
@ -23,7 +23,7 @@ simplexChatCore cfg@ChatConfig {dbPoolSize, yesToMigrations} opts sendToast chat
|
|||||||
where
|
where
|
||||||
initRun = do
|
initRun = do
|
||||||
let f = chatStoreFile $ dbFilePrefix opts
|
let f = chatStoreFile $ dbFilePrefix opts
|
||||||
st <- createStore f dbPoolSize yesToMigrations
|
st <- createStore f yesToMigrations
|
||||||
u <- getCreateActiveUser st
|
u <- getCreateActiveUser st
|
||||||
cc <- newChatController st (Just u) cfg opts sendToast
|
cc <- newChatController st (Just u) cfg opts sendToast
|
||||||
runSimplexChat opts u cc chat
|
runSimplexChat opts u cc chat
|
||||||
|
@ -90,7 +90,7 @@ getActiveUser_ st = find activeUser <$> getUsers st
|
|||||||
chatInit :: String -> IO ChatController
|
chatInit :: String -> IO ChatController
|
||||||
chatInit dbFilePrefix = do
|
chatInit dbFilePrefix = do
|
||||||
let f = chatStoreFile dbFilePrefix
|
let f = chatStoreFile dbFilePrefix
|
||||||
chatStore <- createStore f (dbPoolSize defaultMobileConfig) (yesToMigrations (defaultMobileConfig :: ChatConfig))
|
chatStore <- createStore f (yesToMigrations (defaultMobileConfig :: ChatConfig))
|
||||||
user_ <- getActiveUser_ chatStore
|
user_ <- getActiveUser_ chatStore
|
||||||
newChatController chatStore user_ defaultMobileConfig mobileChatOpts {dbFilePrefix} Nothing
|
newChatController chatStore user_ defaultMobileConfig mobileChatOpts {dbFilePrefix} Nothing
|
||||||
|
|
||||||
|
@ -237,8 +237,8 @@ migrations = sortBy (compare `on` name) $ map migration schemaMigrations
|
|||||||
where
|
where
|
||||||
migration (name, query) = Migration {name = name, up = fromQuery query}
|
migration (name, query) = Migration {name = name, up = fromQuery query}
|
||||||
|
|
||||||
createStore :: FilePath -> Int -> Bool -> IO SQLiteStore
|
createStore :: FilePath -> Bool -> IO SQLiteStore
|
||||||
createStore dbFilePath poolSize = createSQLiteStore dbFilePath poolSize migrations
|
createStore dbFilePath = createSQLiteStore dbFilePath migrations
|
||||||
|
|
||||||
chatStoreFile :: FilePath -> FilePath
|
chatStoreFile :: FilePath -> FilePath
|
||||||
chatStoreFile = (<> "_chat.db")
|
chatStoreFile = (<> "_chat.db")
|
||||||
|
@ -49,7 +49,7 @@ extra-deps:
|
|||||||
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
|
# - simplexmq-1.0.0@sha256:34b2004728ae396e3ae449cd090ba7410781e2b3cefc59259915f4ca5daa9ea8,8561
|
||||||
# - ../simplexmq
|
# - ../simplexmq
|
||||||
- github: simplex-chat/simplexmq
|
- github: simplex-chat/simplexmq
|
||||||
commit: c1348aa54fba292d34339d6b111572cb1c74b546
|
commit: 5f94240ed420c42c725810b72b7f512ab320a98f
|
||||||
# - terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
|
# - terminal-0.2.0.0@sha256:de6770ecaae3197c66ac1f0db5a80cf5a5b1d3b64a66a05b50f442de5ad39570,2977
|
||||||
- github: simplex-chat/aeson
|
- github: simplex-chat/aeson
|
||||||
commit: 3eb66f9a68f103b5f1489382aad89f5712a64db7
|
commit: 3eb66f9a68f103b5f1489382aad89f5712a64db7
|
||||||
|
@ -99,14 +99,14 @@ testCfgV1 = testCfg {agentConfig = testAgentCfgV1}
|
|||||||
createTestChat :: ChatConfig -> ChatOpts -> String -> Profile -> IO TestCC
|
createTestChat :: ChatConfig -> ChatOpts -> String -> Profile -> IO TestCC
|
||||||
createTestChat cfg opts dbPrefix profile = do
|
createTestChat cfg opts dbPrefix profile = do
|
||||||
let dbFilePrefix = testDBPrefix <> dbPrefix
|
let dbFilePrefix = testDBPrefix <> dbPrefix
|
||||||
st <- createStore (dbFilePrefix <> "_chat.db") 1 False
|
st <- createStore (dbFilePrefix <> "_chat.db") False
|
||||||
Right user <- runExceptT $ createUser st profile True
|
Right user <- runExceptT $ createUser st profile True
|
||||||
startTestChat_ st cfg opts dbFilePrefix user
|
startTestChat_ st cfg opts dbFilePrefix user
|
||||||
|
|
||||||
startTestChat :: ChatConfig -> ChatOpts -> String -> IO TestCC
|
startTestChat :: ChatConfig -> ChatOpts -> String -> IO TestCC
|
||||||
startTestChat cfg opts dbPrefix = do
|
startTestChat cfg opts dbPrefix = do
|
||||||
let dbFilePrefix = testDBPrefix <> dbPrefix
|
let dbFilePrefix = testDBPrefix <> dbPrefix
|
||||||
st <- createStore (dbFilePrefix <> "_chat.db") 1 False
|
st <- createStore (dbFilePrefix <> "_chat.db") False
|
||||||
Just user <- find activeUser <$> getUsers st
|
Just user <- find activeUser <$> getUsers st
|
||||||
startTestChat_ st cfg opts dbFilePrefix user
|
startTestChat_ st cfg opts dbFilePrefix user
|
||||||
|
|
||||||
@ -262,6 +262,7 @@ serverCfg =
|
|||||||
queueIdBytes = 12,
|
queueIdBytes = 12,
|
||||||
msgIdBytes = 6,
|
msgIdBytes = 6,
|
||||||
storeLogFile = Nothing,
|
storeLogFile = Nothing,
|
||||||
|
storeMsgsFile = Nothing,
|
||||||
allowNewQueues = True,
|
allowNewQueues = True,
|
||||||
messageExpiration = Just defaultMessageExpiration,
|
messageExpiration = Just defaultMessageExpiration,
|
||||||
inactiveClientExpiration = Just defaultInactiveClientExpiration,
|
inactiveClientExpiration = Just defaultInactiveClientExpiration,
|
||||||
|
@ -2171,6 +2171,7 @@ testMaintenanceModeWithFiles = withTmpFiles $ do
|
|||||||
alice <## "completed receiving file 1 (test.jpg) from bob"
|
alice <## "completed receiving file 1 (test.jpg) from bob"
|
||||||
src <- B.readFile "./tests/fixtures/test.jpg"
|
src <- B.readFile "./tests/fixtures/test.jpg"
|
||||||
B.readFile "./tests/tmp/alice_files/test.jpg" `shouldReturn` src
|
B.readFile "./tests/tmp/alice_files/test.jpg" `shouldReturn` src
|
||||||
|
threadDelay 500000
|
||||||
alice ##> "/_stop"
|
alice ##> "/_stop"
|
||||||
alice <## "chat stopped"
|
alice <## "chat stopped"
|
||||||
alice ##> "/_db export {\"archivePath\": \"./tests/tmp/alice-chat.zip\"}"
|
alice ##> "/_db export {\"archivePath\": \"./tests/tmp/alice-chat.zip\"}"
|
||||||
|
@ -82,7 +82,7 @@ testChatApiNoUser = withTmpFiles $ do
|
|||||||
testChatApi :: IO ()
|
testChatApi :: IO ()
|
||||||
testChatApi = withTmpFiles $ do
|
testChatApi = withTmpFiles $ do
|
||||||
let f = chatStoreFile $ testDBPrefix <> "1"
|
let f = chatStoreFile $ testDBPrefix <> "1"
|
||||||
st <- createStore f 1 True
|
st <- createStore f True
|
||||||
Right _ <- runExceptT $ createUser st aliceProfile True
|
Right _ <- runExceptT $ createUser st aliceProfile True
|
||||||
cc <- chatInit $ testDBPrefix <> "1"
|
cc <- chatInit $ testDBPrefix <> "1"
|
||||||
chatSendCmd cc "/u" `shouldReturn` activeUser
|
chatSendCmd cc "/u" `shouldReturn` activeUser
|
||||||
|
@ -21,7 +21,7 @@ schemaDumpTest =
|
|||||||
testVerifySchemaDump :: IO ()
|
testVerifySchemaDump :: IO ()
|
||||||
testVerifySchemaDump =
|
testVerifySchemaDump =
|
||||||
withTmpFiles $ do
|
withTmpFiles $ do
|
||||||
void $ createStore testDB 1 False
|
void $ createStore testDB False
|
||||||
void $ readCreateProcess (shell $ "touch " <> schema) ""
|
void $ readCreateProcess (shell $ "touch " <> schema) ""
|
||||||
savedSchema <- readFile schema
|
savedSchema <- readFile schema
|
||||||
savedSchema `seq` pure ()
|
savedSchema `seq` pure ()
|
||||||
|
Loading…
Reference in New Issue
Block a user