35 lines
1.4 KiB
Go
35 lines
1.4 KiB
Go
// Package app is the composition root for the running administration service.
|
|
// It knows which business modules are enabled and wires their contributions
|
|
// into the shared platform. Individual modules do not import this package.
|
|
package app
|
|
|
|
import (
|
|
systemmodule "kra/app/system/internal/module"
|
|
systemserver "kra/app/system/internal/server"
|
|
systemworker "kra/app/system/internal/worker"
|
|
"kra/pkg/module"
|
|
platformtask "kra/pkg/task"
|
|
)
|
|
|
|
// Catalog lists the business modules enabled in this binary. Adding an order
|
|
// module means adding one Definition here; system initialization and runtime
|
|
// code consume the catalog without knowing that module's implementation.
|
|
func Catalog() module.Catalog {
|
|
return module.Catalog{Definitions: []module.Definition{systemmodule.Definition()}}
|
|
}
|
|
|
|
// TaskRegistry builds the process-wide registry from dependency-free module
|
|
// contributions. Dependency-bearing methods are added by their module runtime
|
|
// constructors after the usecases have been created.
|
|
func TaskRegistry(catalog module.Catalog) *platformtask.Registry {
|
|
registry := platformtask.NewRegistry()
|
|
registry.RegisterAll(catalog.TaskMethods())
|
|
return registry
|
|
}
|
|
|
|
// Runtime composes HTTP route contributors from the enabled modules.
|
|
func Runtime(systemRoutes *systemserver.Routes, systemTasks *systemworker.TaskMethods, registry *platformtask.Registry) *module.Runtime {
|
|
platformtask.Apply(registry, systemTasks)
|
|
return module.NewRuntime(systemRoutes)
|
|
}
|