blob: 4d69556b163ad954af980110ae8d4b6eef8d46d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package tasks
import (
"sync"
"github.com/seaweedfs/seaweedfs/weed/admin/config"
)
// TaskConfigSchema defines the schema for task configuration
type TaskConfigSchema struct {
config.Schema // Embed common schema functionality
TaskName string `json:"task_name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Icon string `json:"icon"`
}
// TaskConfigSchemaProvider is an interface for providing task configuration schemas
type TaskConfigSchemaProvider interface {
GetConfigSchema() *TaskConfigSchema
}
// schemaRegistry maintains a registry of schema providers by task type
type schemaRegistry struct {
providers map[string]TaskConfigSchemaProvider
mutex sync.RWMutex
}
var globalSchemaRegistry = &schemaRegistry{
providers: make(map[string]TaskConfigSchemaProvider),
}
// RegisterTaskConfigSchema registers a schema provider for a task type
func RegisterTaskConfigSchema(taskType string, provider TaskConfigSchemaProvider) {
globalSchemaRegistry.mutex.Lock()
defer globalSchemaRegistry.mutex.Unlock()
globalSchemaRegistry.providers[taskType] = provider
}
// GetTaskConfigSchema returns the schema for the specified task type
func GetTaskConfigSchema(taskType string) *TaskConfigSchema {
globalSchemaRegistry.mutex.RLock()
provider, exists := globalSchemaRegistry.providers[taskType]
globalSchemaRegistry.mutex.RUnlock()
if !exists {
return nil
}
return provider.GetConfigSchema()
}
|