aboutsummaryrefslogtreecommitdiff
path: root/weed/worker/tasks/base/registration.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-08-01 11:18:32 -0700
committerGitHub <noreply@github.com>2025-08-01 11:18:32 -0700
commit0975968e71b05368d5f28f788cf863c2042c2696 (patch)
tree5162a5fe3d9c88fb43f49f57326a4fd5b8cde74c /weed/worker/tasks/base/registration.go
parent1cba609bfa2306cc2885df212febd5ff954aa693 (diff)
downloadseaweedfs-0975968e71b05368d5f28f788cf863c2042c2696.tar.xz
seaweedfs-0975968e71b05368d5f28f788cf863c2042c2696.zip
admin: Refactor task destination planning (#7063)
* refactor planning into task detection * refactoring worker tasks * refactor * compiles, but only balance task is registered * compiles, but has nil exception * avoid nil logger * add back ec task * setting ec log directory * implement balance and vacuum tasks * EC tasks will no longer fail with "file not found" errors * Use ReceiveFile API to send locally generated shards * distributing shard files and ecx,ecj,vif files * generate .ecx files correctly * do not mount all possible EC shards (0-13) on every destination * use constants * delete all replicas * rename files * pass in volume size to tasks
Diffstat (limited to 'weed/worker/tasks/base/registration.go')
-rw-r--r--weed/worker/tasks/base/registration.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/weed/worker/tasks/base/registration.go b/weed/worker/tasks/base/registration.go
index 416b6f6b8..bef96d291 100644
--- a/weed/worker/tasks/base/registration.go
+++ b/weed/worker/tasks/base/registration.go
@@ -29,13 +29,28 @@ func NewGenericFactory(taskDef *TaskDefinition) *GenericFactory {
}
// Create creates a task instance using the task definition
-func (f *GenericFactory) Create(params types.TaskParams) (types.TaskInterface, error) {
+func (f *GenericFactory) Create(params *worker_pb.TaskParams) (types.Task, error) {
if f.taskDef.CreateTask == nil {
return nil, fmt.Errorf("no task creation function defined for %s", f.taskDef.Type)
}
return f.taskDef.CreateTask(params)
}
+// Type returns the task type
+func (f *GenericFactory) Type() string {
+ return string(f.taskDef.Type)
+}
+
+// Description returns a description of what this task does
+func (f *GenericFactory) Description() string {
+ return f.taskDef.Description
+}
+
+// Capabilities returns the task capabilities
+func (f *GenericFactory) Capabilities() []string {
+ return f.taskDef.Capabilities
+}
+
// GenericSchemaProvider provides config schema from TaskDefinition
type GenericSchemaProvider struct {
taskDef *TaskDefinition
@@ -149,7 +164,8 @@ func validateTaskDefinition(taskDef *TaskDefinition) error {
if taskDef.Config == nil {
return fmt.Errorf("task config is required")
}
- // CreateTask is optional for tasks that use the typed task system
- // The typed system registers tasks separately via types.RegisterGlobalTypedTask()
+ if taskDef.CreateTask == nil {
+ return fmt.Errorf("task creation function is required")
+ }
return nil
}