yao/flow/flow.go
Max fabced291c fix: Enhance loading functions to handle non-existent directories
- Added checks in various loading functions to ignore processing if the respective directories do not exist, improving error handling and preventing unnecessary operations.
- Updated the Load function signature to return warnings alongside errors, allowing for better feedback on loading issues across different components.
2025-05-13 09:10:10 +08:00

30 lines
642 B
Go

package flow
import (
"github.com/yaoapp/gou/application"
"github.com/yaoapp/gou/flow"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/share"
)
// Load 加载业务逻辑编排
func Load(cfg config.Config) error {
// Ignore if the flows directory does not exist
exists, err := application.App.Exists("flows")
if err != nil {
return err
}
if !exists {
return nil
}
exts := []string{"*.flow.yao", "*.flow.json", "*.flow.jsonc"}
return application.App.Walk("flows", func(root, file string, isdir bool) error {
if isdir {
return nil
}
_, err := flow.Load(file, share.ID(root, file))
return err
}, exts...)
}