优化结构

This commit is contained in:
Yvan
2026-08-27 16:20:37 +08:00
parent 001e39da50
commit 653414a1da
54 changed files with 1257 additions and 3450 deletions
+11 -8
View File
@@ -8,7 +8,6 @@ import (
"os"
"strings"
"kra/internal/app"
"kra/internal/config"
"kra/internal/server/router"
"kra/internal/service"
@@ -50,13 +49,17 @@ func init() {
flag.StringVar(&flagconf, "conf", "./configs", "config path, eg: -conf config.yaml")
}
// runtimeContributions is the binary-level list of modules with constructed
// route or task dependencies. Adding another runtime module is explicit here.
func runtimeContributions(systemRoutes *router.Routes, systemTasks *worker.TaskMethods) app.Composition {
return app.Composition{
Routes: []module.RouteRegistrar{systemRoutes},
Tasks: []platformtask.Contributor{systemTasks},
}
// taskRegistry builds the process-wide registry from the dependency-free task
// methods the static module catalog declares. Methods whose handlers need
// constructed usecases are added later by buildRuntime.
func taskRegistry() *platformtask.Registry { return platformtask.NewRegistry() }
// buildRuntime is the binary-level list of modules with constructed route or
// task dependencies: it activates their task methods and composes their routes.
// Adding another runtime module is explicit here.
func buildRuntime(registry *platformtask.Registry, systemRoutes *router.Routes, systemTasks *worker.TaskMethods) module.RouteRegistrar {
systemTasks.RegisterTasks(registry)
return systemRoutes
}
func newApp(logger *slog.Logger, hs *kratoshttp.Server, scheduler *worker.TaskScheduler, audit *service.AuditRecorder, loggerControl *logging.ReloadableLogger, _ mq.Client) *kratos.App {