taolib.symphony.config.watcher#
Symphony 文件监视器。
基于 watchdog 监视 WORKFLOW.md 文件变更, 防抖后触发重新加载,验证失败时保持最后有效配置。
Attributes#
Classes#
WORKFLOW.md 文件变更事件处理器。 |
|
WORKFLOW.md 文件监视器。 |
Module Contents#
- taolib.symphony.config.watcher.logger#
- taolib.symphony.config.watcher._DEBOUNCE_MS = 500#
- taolib.symphony.config.watcher.OnReloadSuccess#
- taolib.symphony.config.watcher.OnReloadError#
- class taolib.symphony.config.watcher._WorkflowEventHandler(workflow_path: pathlib.Path, on_reload_success: OnReloadSuccess | None, on_reload_error: OnReloadError | None)#
Bases:
watchdog.events.FileSystemEventHandlerWORKFLOW.md 文件变更事件处理器。
实现防抖逻辑:收到变更事件后等待 _DEBOUNCE_MS, 如果期间没有新的变更事件则触发重新加载。
- _workflow_path#
- _on_reload_success#
- _on_reload_error#
- _last_valid_config: taolib.symphony.config.schema.SymphonyConfig | None = None#
- _debounce_seconds = 0.5#
- on_modified(event: watchdog.events.FileModifiedEvent) None#
Called when a file or directory is modified.
- 参数:
event (
DirModifiedEventorFileModifiedEvent) -- Event representing file/directory modification.
- property last_valid_config: taolib.symphony.config.schema.SymphonyConfig | None#
返回最后有效的配置。
- class taolib.symphony.config.watcher.WorkflowWatcher(workflow_path: pathlib.Path, on_reload_success: OnReloadSuccess | None = None, on_reload_error: OnReloadError | None = None)#
WORKFLOW.md 文件监视器。
基于 watchdog 监视指定的工作流文件,变更时重新加载并验证配置。 验证失败则保持最后有效配置,不会使服务崩溃。
使用方式:
- watcher = WorkflowWatcher(
workflow_path=Path("WORKFLOW.md"), on_reload_success=my_success_handler, on_reload_error=my_error_handler,
) watcher.start() # ... 服务运行 ... watcher.stop()
- _workflow_path#
- _handler#
- property last_valid_config: taolib.symphony.config.schema.SymphonyConfig | None#
返回最后有效的配置。