This commit is contained in:
vet
2026-05-28 00:16:19 +08:00
commit 52446ccf3f
54 changed files with 4617 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package executor
import (
"context"
"fmt"
"scheduler-backend/internal/jobdef"
)
type Service struct {
registry *jobdef.Registry
runtime jobdef.Runtime
}
func NewService(registry *jobdef.Registry, runtime jobdef.Runtime) *Service {
return &Service{
registry: registry,
runtime: runtime,
}
}
func (s *Service) Execute(ctx context.Context, handlerKey string, req jobdef.ExecuteRequest) error {
handler, ok := s.registry.Get(handlerKey)
if !ok {
return fmt.Errorf("handler %s not found", handlerKey)
}
if req.LogCollector == nil {
req.LogCollector = jobdef.NewLogCollector()
}
return handler.Run(ctx, s.runtime, req)
}