refactor: make no transport error an exported error we can test on
This commit is contained in:
parent
701386c05d
commit
397ed0d6ec
|
@ -6,6 +6,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrTransportNotSupported = errors.New("no static method registered for type")
|
||||||
|
)
|
||||||
|
|
||||||
type TransportPeerConfig struct {
|
type TransportPeerConfig struct {
|
||||||
Socket interface{}
|
Socket interface{}
|
||||||
Uris []*url.URL
|
Uris []*url.URL
|
||||||
|
@ -43,7 +47,7 @@ func RegisterTransport(peerType string, factory interface{}) {
|
||||||
func CreateTransportSocket(peerType string, uri *url.URL) (interface{}, error) {
|
func CreateTransportSocket(peerType string, uri *url.URL) (interface{}, error) {
|
||||||
static, ok := transports.Load(peerType)
|
static, ok := transports.Load(peerType)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("no static method registered for type: " + peerType)
|
return nil, ErrTransportNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := static.(PeerStatic).Connect(uri)
|
t, err := static.(PeerStatic).Connect(uri)
|
||||||
|
|
Loading…
Reference in New Issue