29 lines
885 B
Go
29 lines
885 B
Go
package task
|
|
|
|
import platformtask "kra/pkg/task"
|
|
|
|
type TaskMethodFunc = platformtask.MethodFunc
|
|
type TaskMethod = platformtask.Method
|
|
|
|
type TaskMethodRegistry interface {
|
|
Register(platformtask.Method)
|
|
Lookup(string) (TaskMethodFunc, bool)
|
|
List() []TaskMethod
|
|
}
|
|
|
|
var defaultTaskMethods = platformtask.NewRegistry()
|
|
|
|
// RegisterTaskMethod remains as a compatibility helper for tests and callers
|
|
// that have not moved to constructor injection yet.
|
|
func RegisterTaskMethod(name, description string, fn TaskMethodFunc) {
|
|
defaultTaskMethods.Register(platformtask.Method{Name: name, Description: description, Run: fn})
|
|
}
|
|
|
|
func TaskMethodByName(name string) (TaskMethodFunc, bool) {
|
|
return defaultTaskMethods.Lookup(name)
|
|
}
|
|
|
|
func RegisteredTaskMethods() []TaskMethod { return defaultTaskMethods.List() }
|
|
|
|
func DefaultTaskMethodRegistry() TaskMethodRegistry { return defaultTaskMethods }
|