mirror of
https://github.com/zrepl/zrepl.git
synced 2025-02-28 08:15:03 +01:00
27 lines
580 B
Go
27 lines
580 B
Go
|
package serve
|
||
|
|
||
|
import (
|
||
|
"github.com/pkg/errors"
|
||
|
"github.com/zrepl/zrepl/config"
|
||
|
"net"
|
||
|
)
|
||
|
|
||
|
type ListenerFactory interface {
|
||
|
Listen() (net.Listener, error)
|
||
|
}
|
||
|
|
||
|
func FromConfig(g config.Global, in config.ServeEnum) (ListenerFactory, error) {
|
||
|
|
||
|
switch v := in.Ret.(type) {
|
||
|
case *config.TCPServe:
|
||
|
return TCPListenerFactoryFromConfig(g, v)
|
||
|
case *config.TLSServe:
|
||
|
return TLSListenerFactoryFromConfig(g, v)
|
||
|
case *config.StdinserverServer:
|
||
|
return StdinserverListenerFactoryFromConfig(g, v)
|
||
|
default:
|
||
|
return nil, errors.Errorf("internal error: unknown serve type %T", v)
|
||
|
}
|
||
|
|
||
|
}
|