You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							51 lines
						
					
					
						
							1.4 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							51 lines
						
					
					
						
							1.4 KiB
						
					
					
				| 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() | |
| }
 |