Peter Kurfer
9236a38be0
- introduce new endpoints module - introduce Endpoint and EndpointManager - introduce new Logging abstraction API to allow proper mocking - add error return value to Start and Shutdown of endpoints - add mocks of some internals to allow easier testing - add generate target to take care of all code generation
26 lines
684 B
Go
26 lines
684 B
Go
package config
|
|
|
|
import "github.com/spf13/viper"
|
|
|
|
func CreateMultiHandlerConfig(handlerConfig *viper.Viper) MultiHandlerConfig {
|
|
return NewMultiHandlerConfig(
|
|
handlerConfig.GetString(pluginConfigKey),
|
|
portsFromConfig(handlerConfig),
|
|
handlerConfig.GetString(listenAddressConfigKey),
|
|
handlerConfig.Sub(OptionsKey),
|
|
)
|
|
}
|
|
|
|
func portsFromConfig(handlerConfig *viper.Viper) (ports []uint16) {
|
|
if portsInt := handlerConfig.GetIntSlice(portsConfigKey); len(portsInt) > 0 {
|
|
for _, port := range portsInt {
|
|
ports = append(ports, uint16(port))
|
|
}
|
|
return
|
|
}
|
|
|
|
if portInt := handlerConfig.GetInt(portConfigKey); portInt > 0 {
|
|
ports = append(ports, uint16(portInt))
|
|
}
|
|
return
|
|
}
|