mirror of
https://github.com/zrepl/zrepl.git
synced 2024-12-04 14:27:03 +01:00
c69ebd3806
cmd subdir does not build on purpose, it's only left in tree to grab old code and move it to github.com/zrepl/zrepl/daemon
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)
|
|
}
|
|
|
|
}
|