fix(registry): log Unregister Close errors, add doc comments and 59 unit tests
Log close errors in Unregister instead of silently discarding them. Add doc comments to all exported symbols across 20 registry files. Add comprehensive tests covering base registry, all wrapper types, hot-reload delegation, nil-fallback semantics, and global accessors.
This commit is contained in:
@@ -8,14 +8,18 @@ import (
|
||||
"github.com/go-gost/core/selector"
|
||||
)
|
||||
|
||||
// chainRegistry implements a hot-reload-safe registry for chain.Chainer.
|
||||
type chainRegistry struct {
|
||||
registry[chain.Chainer]
|
||||
}
|
||||
|
||||
// Register stores a Chainer under the given name.
|
||||
func (r *chainRegistry) Register(name string, v chain.Chainer) error {
|
||||
return r.registry.Register(name, v)
|
||||
}
|
||||
|
||||
// Get returns a wrapper that delegates to the currently registered Chainer.
|
||||
// Returns nil if name is empty.
|
||||
func (r *chainRegistry) Get(name string) chain.Chainer {
|
||||
if name != "" {
|
||||
return &chainWrapper{name: name, r: r}
|
||||
|
||||
Reference in New Issue
Block a user