feat(core): implement app profile lifecycle dispatcher and wire cli commands

This commit is contained in:
ryan
2026-08-28 00:02:30 +08:00
parent a4c3f70f0b
commit b6bfa120fc
16 changed files with 1471 additions and 98 deletions
+1 -1
View File
@@ -210,7 +210,7 @@ func (p *Plugin) Apply(ctx *core.Context) error {
}
// 2. Register Background Tasks
ctx.Task().Register("admin:system_cleanup", func(c context.Context, t *asynq.Task) error {
ctx.Task().Register("admin:system_cleanup", func(_ context.Context, _ *asynq.Task) error {
return nil
}, extpoints.WithTaskRetry(1))
+1 -1
View File
@@ -101,7 +101,7 @@ func (s *authServiceImpl) VerifyToken(ctx context.Context, token string) (*contr
return toUserDTO(user), nil
}
func (s *authServiceImpl) CreateSession(ctx context.Context, userID uint64, extras map[string]any) (string, error) {
func (s *authServiceImpl) CreateSession(_ context.Context, _ uint64, _ map[string]any) (string, error) {
// Session creation helper
return "", nil
}
+8 -6
View File
@@ -70,12 +70,14 @@ func (p *Plugin) Apply(ctx *core.Context) error {
mgGroup.DELETE("/bindings/:id", appgw.UnbindBinding)
}
// 3. Register Asynq background tasks
ctx.Task().Register("message_gateway:push_notification", func(c context.Context, t *asynq.Task) error {
return nil
}, extpoints.WithTaskRetry(3))
const defaultTaskRetry = 3
ctx.Task().Register("message_gateway:dispatch_bot_msg", func(c context.Context, t *asynq.Task) error {
// 3. Register Asynq background tasks
ctx.Task().Register("message_gateway:push_notification", func(_ context.Context, _ *asynq.Task) error {
return nil
}, extpoints.WithTaskRetry(defaultTaskRetry))
ctx.Task().Register("message_gateway:dispatch_bot_msg", func(_ context.Context, _ *asynq.Task) error {
return nil
})
@@ -83,7 +85,7 @@ func (p *Plugin) Apply(ctx *core.Context) error {
ctx.Schedule().RegisterCron("*/10 * * * *", "message_gateway:cleanup_pairing_codes", map[string]any{"action": "cleanup"})
// 5. Register EventBus listeners for decoupled push triggers
ctx.Events().On("notification:push", func(c context.Context, e PushNotificationEvent) error {
ctx.Events().On("notification:push", func(_ context.Context, _ PushNotificationEvent) error {
// Event triggered push handling
return nil
})
+5 -3
View File
@@ -88,13 +88,15 @@ func (p *Plugin) Apply(ctx *core.Context) error {
}
}
const defaultUserTaskRetry = 3
// 4. Register Asynq background tasks
ctx.Task().Register("user:send_email_code", func(c context.Context, t *asynq.Task) error {
ctx.Task().Register("user:send_email_code", func(_ context.Context, _ *asynq.Task) error {
// Asynq background task handler
return nil
}, extpoints.WithTaskRetry(3))
}, extpoints.WithTaskRetry(defaultUserTaskRetry))
ctx.Task().Register("user:cleanup_inactive", func(c context.Context, t *asynq.Task) error {
ctx.Task().Register("user:cleanup_inactive", func(_ context.Context, _ *asynq.Task) error {
return nil
})
+1 -1
View File
@@ -166,7 +166,7 @@ func (s *userServiceImpl) VerifyPassword(ctx context.Context, id uint64, passwor
return user.CheckPassword(password)
}
func (s *userServiceImpl) UpdateLastLogin(ctx context.Context, id uint64, ip string) error {
func (s *userServiceImpl) UpdateLastLogin(ctx context.Context, id uint64, _ string) error {
return db.DB(ctx).Model(&model.User{}).Where("id = ?", id).
Updates(map[string]any{
"last_login_at": time.Now(),