Use stm-containers Map in memory for concurrent read/writes
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
module Main where
|
||||
|
||||
import Soostone ( app, middleWare, AppState(AppState, sqliteFile) )
|
||||
import Soostone ( app, middleWare, AppState(AppState, sqliteFile, stmMap) )
|
||||
|
||||
import Control.Monad ( void, when )
|
||||
import Data.Version (showVersion)
|
||||
@@ -34,6 +34,7 @@ import Prometheus ( register )
|
||||
import Prometheus.Metric.GHC ( ghcMetrics )
|
||||
import Prometheus.Metric.Proc ( procMetrics )
|
||||
import Text.Read ( readEither )
|
||||
import qualified StmContainers.Map as SM
|
||||
|
||||
|
||||
versioner :: Parser (a -> a)
|
||||
@@ -98,7 +99,8 @@ main = do
|
||||
case serverCommand of
|
||||
Run ServerConfig{..} -> do
|
||||
when (sqliteDB == ":memory:") $ fail "In-memory DB is not supported!"
|
||||
let appState = AppState { sqliteFile = sqliteDB }
|
||||
m <- SM.newIO
|
||||
let appState = AppState { sqliteFile = sqliteDB, stmMap = m }
|
||||
void $ register ghcMetrics
|
||||
void $ register procMetrics
|
||||
run serverPort (middleWare $ app appState)
|
||||
|
||||
Reference in New Issue
Block a user