优化结构

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
-18
View File
@@ -17,13 +17,6 @@ type Method struct {
Run MethodFunc
}
// Contributor registers task methods whose handlers need constructed runtime
// dependencies. Modules expose a contributor and the application composition
// root activates it; the task runtime never imports business modules.
type Contributor interface {
RegisterTasks(*Registry)
}
type Registry struct {
mu sync.RWMutex
methods map[string]Method
@@ -31,17 +24,6 @@ type Registry struct {
func NewRegistry() *Registry { return &Registry{methods: make(map[string]Method)} }
func Apply(registry *Registry, contributors ...Contributor) {
if registry == nil {
return
}
for _, contributor := range contributors {
if contributor != nil {
contributor.RegisterTasks(registry)
}
}
}
func (r *Registry) Register(method Method) {
if r == nil || method.Name == "" || method.Run == nil {
return