Add best exit selection (#486)

* docs: add best exit selection design

* feat: add best exit selection
This commit is contained in:
sagit
2026-05-01 08:12:17 +08:00
committed by GitHub
parent 5e8d0682c0
commit 3f3159aafd
13 changed files with 1557 additions and 77 deletions
+15
View File
@@ -12,10 +12,25 @@ type chainRegistry struct {
registry[chain.Chainer]
}
func ReplaceChain(name string, v chain.Chainer) error {
if name == "" {
return nil
}
if r, ok := chainReg.(*chainRegistry); ok {
r.replace(name, v)
return nil
}
return chainReg.Register(name, v)
}
func (r *chainRegistry) Register(name string, v chain.Chainer) error {
return r.registry.Register(name, v)
}
func (r *chainRegistry) replace(name string, v chain.Chainer) {
r.m.Store(name, v)
}
func (r *chainRegistry) Get(name string) chain.Chainer {
if name != "" {
return &chainWrapper{name: name, r: r}