Minor performance improvements

This commit is contained in:
MasseR committed 2025-04-23 21:59:42 +03:00
1 parent 96454631ea
commit 53e6a66c9e
6 files changed
+38 -20

No files matched your search

+5 -2
View File
@@ -25,6 +25,7 @@ import System.Metrics qualified as EKG
import Tracer (Tracer (..))
import UnliftIO (MonadUnliftIO)
import Wallabag.Auth (Auth, Auth' (..))
import qualified Network.Wreq.Session as Wreq
type KatipTracer = Tracer (Maybe (K.Severity, K.LogStr))
@@ -37,7 +38,8 @@ data S = S
_sWallabagMetrics :: HTTPMetric,
_sOpenrouterMetrics :: HTTPMetric,
_sKatipTracer :: KatipTracer,
_sMetricsStore :: EKG.Store
_sMetricsStore :: EKG.Store,
_sSession :: Wreq.Session
}
deriving (Generic)
@@ -78,6 +80,7 @@ mkKatipTrace le ns = Tracer $ \case
initialS :: Maybe FilePath -> K.Severity -> (S -> IO a) -> IO a
initialS credsPath severity f = do
store <- EKG.newStore
wsession <- Wreq.newSession
EKG.registerGcMetrics store
wbMetrics <-
HTTPMetric
@@ -96,7 +99,7 @@ initialS credsPath severity f = do
let kTrace = mkKatipTrace le ns
ns = "main"
cache <- newTVarIO Unauthenticated
f (S cache ns le mempty c wbMetrics orMetrics kTrace store)
f (S cache ns le mempty c wbMetrics orMetrics kTrace store wsession)
-- TODO: This is just for debug purposes
EKG.sampleAll store >>= mapM_ print . HM.toList
pure res