zrepl/daemon/serve/serve.go
Christian Schwarz c69ebd3806 WIP rewrite the daemon
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
2018-08-27 22:22:44 +02:00

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)
}
}