36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package app
|
||
|
||
import "context"
|
||
|
||
func (a *App) runBackgroundWorkers() {
|
||
if a.walletSvc == nil {
|
||
return
|
||
}
|
||
ctx, cancel := context.WithCancel(context.Background())
|
||
a.stopWorker = cancel
|
||
if a.outboxWorkerCfg.Enabled && a.outboxProducer != nil {
|
||
excludedRealtimeTypes := []string(nil)
|
||
if a.realtimeOutboxWorkerCfg.Enabled && a.realtimeOutboxProducer != nil {
|
||
// 普通账务 worker 在实时通道可用时跳过红包 UI 事件,避免两个 worker 抢同一行。
|
||
excludedRealtimeTypes = a.realtimeOutboxWorkerCfg.EventTypes
|
||
}
|
||
a.startWalletOutboxWorkers(ctx, "wallet-outbox", a.outboxWorkerCfg, a.outboxPartitions, a.outboxProducer, a.walletOutboxTopic, nil, excludedRealtimeTypes)
|
||
}
|
||
if a.realtimeOutboxWorkerCfg.Enabled && a.realtimeOutboxProducer != nil {
|
||
a.startWalletOutboxWorkers(ctx, "wallet-realtime-outbox", a.realtimeOutboxWorkerCfg, a.realtimeOutboxPartitions, a.realtimeOutboxProducer, a.realtimeWalletOutboxTopic, a.realtimeOutboxWorkerCfg.EventTypes, nil)
|
||
}
|
||
if a.outboxArchiveCfg.Enabled {
|
||
// archive-only 与 MQ fanout 独立;dry_run 也持续用有界索引查询暴露容量,但两种模式都不删除热表行。
|
||
a.startWalletOutboxArchiveWorker(ctx)
|
||
}
|
||
if a.externalRechargeReconcileWorkerCfg.Enabled {
|
||
a.startExternalRechargeReconcileWorker(ctx)
|
||
}
|
||
if a.googlePaidSyncWorkerCfg.Enabled {
|
||
a.startGooglePaidSyncWorker(ctx)
|
||
}
|
||
if a.redPacketExpiryWorkerCfg.Enabled {
|
||
a.startRedPacketExpiryWorker(ctx)
|
||
}
|
||
}
|