mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 23:06:36 +08:00
refactor(admin): decouple system cleanup with event bus and enforce single owner principle
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"context"
|
||||
"embed"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@@ -204,6 +205,13 @@ func (p *Plugin) Apply(ctx *core.Context) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
// 8.1 Register system cleanup event listener
|
||||
ctx.Events().On(contracts.EventTopicSystemCleanup, func(c context.Context, _ contracts.SystemCleanupEvent) error {
|
||||
const defaultPushHistoryRetention = 30 * 24 * time.Hour
|
||||
_, err := service.CleanupPushHistories(c, defaultPushHistoryRetention)
|
||||
return err
|
||||
})
|
||||
|
||||
// 9. Register built-in domain events and provide PushRegistry
|
||||
service.RegisterCustomEvents()
|
||||
core.Provide[contracts.PushRegistry](ctx, service.PushRegistryAdapter{})
|
||||
|
||||
Reference in New Issue
Block a user