module Ecluse.Composition.Plan (
resolveMemoryPlanFor,
) where
import Data.Map.Strict qualified as Map
import Ecluse.Composition.MemoryPlan (MemoryPlan, queueTenantDemand, resolveMemoryPlan)
import Ecluse.Composition.MirrorQueue (MirrorRuntimePlan)
import Ecluse.Config (
AppConfig (cfgCache, cfgLimits, cfgMounts, cfgQueue, cfgRuntime),
MountConfig (mntPublicationTarget),
RuntimeSettings (rtServeMaxInFlight),
)
import Ecluse.Rts (EffectiveRuntimePlan)
resolveMemoryPlanFor :: AppConfig -> EffectiveRuntimePlan -> MirrorRuntimePlan -> (MemoryPlan, [Text])
resolveMemoryPlanFor :: AppConfig
-> EffectiveRuntimePlan
-> MirrorRuntimePlan
-> (MemoryPlan, [Text])
resolveMemoryPlanFor AppConfig
appConfig EffectiveRuntimePlan
effective MirrorRuntimePlan
mirrorRuntime =
CacheSettings
-> LimitsSettings
-> QueueSettings
-> Maybe Int
-> EffectiveRuntimePlan
-> QueueTenantDemand
-> Bool
-> (MemoryPlan, [Text])
resolveMemoryPlan
(AppConfig -> CacheSettings
cfgCache AppConfig
appConfig)
(AppConfig -> LimitsSettings
cfgLimits AppConfig
appConfig)
(AppConfig -> QueueSettings
cfgQueue AppConfig
appConfig)
(RuntimeSettings -> Maybe Int
rtServeMaxInFlight (AppConfig -> RuntimeSettings
cfgRuntime AppConfig
appConfig))
EffectiveRuntimePlan
effective
(MirrorRuntimePlan -> QueueTenantDemand
queueTenantDemand MirrorRuntimePlan
mirrorRuntime)
Bool
publishConfigured
where
publishConfigured :: Bool
publishConfigured = (MountConfig -> Bool) -> [MountConfig] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Maybe RegistryUrl -> Bool
forall a. Maybe a -> Bool
isJust (Maybe RegistryUrl -> Bool)
-> (MountConfig -> Maybe RegistryUrl) -> MountConfig -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MountConfig -> Maybe RegistryUrl
mntPublicationTarget) (Map Ecosystem MountConfig -> [MountConfig]
forall k a. Map k a -> [a]
Map.elems (AppConfig -> Map Ecosystem MountConfig
cfgMounts AppConfig
appConfig))