Files
x/registry/connector.go
T
ginuerzh acce86c0e4 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.
2026-05-25 20:23:06 +08:00

26 lines
800 B
Go

package registry
import (
"github.com/go-gost/core/connector"
"github.com/go-gost/core/logger"
)
// NewConnector is a factory function that creates a new connector.Connector
// from the given options.
type NewConnector func(opts ...connector.Option) connector.Connector
// connectorRegistry stores connector factory functions. Duplicate registrations
// are treated as fatal errors (logger.Default().Fatal).
type connectorRegistry struct {
registry[NewConnector]
}
// Register stores a connector factory under the given name. Calls Fatal on
// duplicate registration since connector names must be unique at init time.
func (r *connectorRegistry) Register(name string, v NewConnector) error {
if err := r.registry.Register(name, v); err != nil {
logger.Default().Fatal(err)
}
return nil
}