@@ -12,6 +12,7 @@ import (
1212 "github.com/utmstack/utmstack/backend/modules/alerts"
1313 "github.com/utmstack/utmstack/backend/modules/appconfig"
1414 "github.com/utmstack/utmstack/backend/modules/audit"
15+ "github.com/utmstack/utmstack/backend/modules/billing"
1516 "github.com/utmstack/utmstack/backend/modules/compliance"
1617 "github.com/utmstack/utmstack/backend/modules/dashboards"
1718 "github.com/utmstack/utmstack/backend/modules/datasources"
@@ -52,6 +53,7 @@ type modules struct {
5253 iam * iam.Module
5354 audit * audit.Module
5455 appconfig * appconfig.Module
56+ billing * billing.Module
5557 mail * mail.Module
5658 compliance * compliance.Module
5759 dashboards * dashboards.Module
@@ -89,6 +91,7 @@ func initModules(db *gorm.DB, cfg *config) *modules {
8991 limiter := ratelimit .NewLoginLimiter (loginMaxFailures , loginBlockTTL , loginWindowTTL )
9092
9193 auditMod := audit .NewModule (db )
94+ billingMod := billing .NewModule (env .String ("UPDATES_DIR" , "/updates" , false ), 25 )
9295 configMod := appconfig .NewModule (db , cipher )
9396 mailMod := mail .NewModule (configMod .Store ())
9497 configMod .SetMailer (mailMod .Service ())
@@ -121,7 +124,7 @@ func initModules(db *gorm.DB, cfg *config) *modules {
121124 _ = catcher .Error ("opensearch SDK connect failed" , err , nil )
122125 }
123126
124- alertsMod := alerts .NewModule (db , env . Bool ( "ALERTS_SCHEDULER_ENABLED" , false ) )
127+ alertsMod := alerts .NewModule (db )
125128
126129 agentClient , agentErr := agentmanager .NewClient ()
127130 if agentErr != nil {
@@ -132,17 +135,20 @@ func initModules(db *gorm.DB, cfg *config) *modules {
132135 soarMod := soar .NewModule (db , agentClient , signer , cipher )
133136 eventProcessingMod := eventprocessing .NewModule (db , auditMod .Logger ())
134137
135- integrationsMod := integrations .NewModule (db , cipher ,
136- env .String ("INTEGRATIONS_TENANT_DIR" , "/workdir/pipeline" , false ),
137- )
138-
139- // datasources: registered log sources (agents, collectors, pullers, direct inputs)
140- // and their groups. Registration + liveness arrive via the ping endpoint.
141138 dsRepo := ns_repository .NewDatasourceRepository (db )
142139 dsGroupRepo := ns_repository .NewAssetGroupRepository (db )
143140 dsUC := ns_usecase .NewDatasourceUsecase (dsRepo )
144141 dsGroupUC := ns_usecase .NewAssetGroupUsecase (dsGroupRepo )
145- datasourcesMod := datasources .NewModule (dsUC , dsGroupUC )
142+ var dsReconciler * ns_usecase.StatsReconciler
143+ if cfg .esHost != "" {
144+ dsReconciler = ns_usecase .NewStatsReconciler (dsRepo , ns_repository .NewStatsReader ())
145+ }
146+ datasourcesMod := datasources .NewModule (dsUC , dsGroupUC , dsReconciler , billingMod .License ())
147+
148+ integrationsMod := integrations .NewModule (db , cipher ,
149+ env .String ("INTEGRATIONS_TENANT_DIR" , "/workdir/pipeline" , false ),
150+ dsUC ,
151+ )
146152
147153 opensearchMod := opensearchgw .NewModule (db , cfg .esHost != "" )
148154 notificationsMod := notifications .NewModule (db , auditMod .Logger ())
@@ -165,6 +171,7 @@ func initModules(db *gorm.DB, cfg *config) *modules {
165171 iam : iam .NewModule (authUsecase , userUsecase , roleUsecase , tfaUsecase , apiKeyUsecase , idpUsecase , samlUsecase , cfg .uploadDir ),
166172 audit : auditMod ,
167173 appconfig : configMod ,
174+ billing : billingMod ,
168175 mail : mailMod ,
169176 compliance : complianceMod ,
170177 dashboards : dashboardsMod ,
0 commit comments