mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 17:56:37 +08:00
feat(core): mount the configuration extension point on the kernel Context
Context 新增 Config() 访问器,注册表随 Fork 共享(配置声明是进程级事实), 并在 types.go 导出配置别名与 ConfigGatedPlugin 可选接口,为插件门禁做准备。
This commit is contained in:
@@ -27,6 +27,7 @@ type Context struct {
|
||||
tasks extpoints.TaskExtension
|
||||
schedules extpoints.ScheduleExtension
|
||||
settings extpoints.SettingExtension
|
||||
config extpoints.ConfigExtension
|
||||
|
||||
mu sync.RWMutex
|
||||
children []*Context
|
||||
@@ -56,6 +57,7 @@ func NewContext(base context.Context) *Context {
|
||||
tasks: extpoints.NewTaskRegistry(),
|
||||
schedules: extpoints.NewScheduleRegistry(),
|
||||
settings: extpoints.NewSettingRegistry(),
|
||||
config: extpoints.NewConfigRegistry(nil),
|
||||
values: make(map[any]any),
|
||||
}
|
||||
}
|
||||
@@ -167,6 +169,7 @@ func (c *Context) ForkWithContext(base context.Context) *Context {
|
||||
tasks: c.tasks,
|
||||
schedules: c.schedules,
|
||||
settings: c.settings,
|
||||
config: c.config,
|
||||
values: make(map[any]any),
|
||||
}
|
||||
|
||||
@@ -235,6 +238,13 @@ func (c *Context) Setting() extpoints.SettingExtension {
|
||||
return c.Settings()
|
||||
}
|
||||
|
||||
// Config returns the process-level configuration extension point. The registry is
|
||||
// shared by every fork because configuration declarations are global facts, and it
|
||||
// carries no per-scope disposers: values are resolved once before Apply runs.
|
||||
func (c *Context) Config() extpoints.ConfigExtension {
|
||||
return c.config
|
||||
}
|
||||
|
||||
// OnDispose registers a cleanup callback function to be executed when this Context is disposed.
|
||||
// It accepts func() error, func(), or Disposer.
|
||||
func (c *Context) OnDispose(fn any) {
|
||||
|
||||
Reference in New Issue
Block a user