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:
ginuerzh
2026-05-25 20:23:06 +08:00
parent b1b7500c2f
commit acce86c0e4
21 changed files with 1150 additions and 1 deletions
+6
View File
@@ -5,12 +5,18 @@ import (
"github.com/go-gost/core/logger"
)
// NewDialer is a factory function that creates a new dialer.Dialer
// from the given options.
type NewDialer func(opts ...dialer.Option) dialer.Dialer
// dialerRegistry stores dialer factory functions. Duplicate registrations
// are treated as fatal errors (logger.Default().Fatal).
type dialerRegistry struct {
registry[NewDialer]
}
// Register stores a dialer factory under the given name. Calls Fatal on
// duplicate registration since dialer names must be unique at init time.
func (r *dialerRegistry) Register(name string, v NewDialer) error {
if err := r.registry.Register(name, v); err != nil {
logger.Default().Fatal(err)