mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-06 07:36:37 +08:00
feat(core): add skipped fiber state for configuration gates
Fiber 新增 SKIPPED 态与 Skip/Skipped 方法:门禁为假的插件在 Apply 之前 即被排除并释放其作用域 Context,为互斥实现(cache 与 cache_memory 等) 同时挂载由内核择一激活铺路。
This commit is contained in:
@@ -27,6 +27,10 @@ const (
|
||||
|
||||
// FiberDisposed indicates the plugin has been completely unmounted and its context disposed.
|
||||
FiberDisposed FiberState = "DISPOSED"
|
||||
|
||||
// FiberSkipped indicates the plugin never activated because its configuration gate
|
||||
// evaluated to false, so an alternative provider took over.
|
||||
FiberSkipped FiberState = "SKIPPED"
|
||||
)
|
||||
|
||||
// Fiber wraps a Plugin instance with a dedicated scoped Context and manages its
|
||||
@@ -134,6 +138,26 @@ func (f *Fiber) Load() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Skip transitions a pending plugin to FiberSkipped and releases its scoped Context.
|
||||
// Active plugins are left untouched, which makes the call safe to replay on every
|
||||
// reconciliation pass, including for plugins mounted after the first gate evaluation.
|
||||
func (f *Fiber) Skip() error {
|
||||
f.mu.Lock()
|
||||
if f.state != FiberPending {
|
||||
f.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
f.state = FiberSkipped
|
||||
f.mu.Unlock()
|
||||
|
||||
return f.ctx.Dispose()
|
||||
}
|
||||
|
||||
// Skipped reports whether the plugin was excluded by its configuration gate.
|
||||
func (f *Fiber) Skipped() bool {
|
||||
return f.State() == FiberSkipped
|
||||
}
|
||||
|
||||
// Unload tears down the plugin: ACTIVE -> UNLOADING -> DISPOSED.
|
||||
func (f *Fiber) Unload() error {
|
||||
f.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user