func (c *Config) ConstructPoolConfig(pool Pool) backend.PoolConfig {
	name, config := pool.Name, pool.Config

	healthzEvery, err := time.ParseDuration(config.HealthzEvery)
	if err != nil {
		logger.Errorf("[config %s] %s is not valid duration", name, config.HealthzEvery)
		healthzEvery = defaultHealthzEvery
	}

	healthzTimeout, err := time.ParseDuration(config.HealthzTimeout)
	if err != nil {
		logger.Errorf("[config %s] %s is not valid duration", name, config.HealthzTimeout)
		healthzTimeout = defaultHealthzTimeout
	}

	requestTimeout, err := time.ParseDuration(config.RequestTimeout)
	if err != nil {
		logger.Errorf("[config %s] %s is not valid duration", name, config.RequestTimeout)
		requestTimeout = defaultRequestTimeout
	}

	status := config.Status
	if !backend.IsValidStatus(status) {
		logger.Errorf("[config %s] %s is not valid status", name, config.Status)
		status = "OK"
	}

	return backend.PoolConfig{
		HealthzEvery:   healthzEvery,
		HealthzTimeout: healthzTimeout,
		RequestTimeout: requestTimeout,
		Status:         status,
	}
}
func TestConstructPoolConfig(t *testing.T) {
	config := NewConfig(routing.DefaultMatcherFactory())

	test := Pool{
		Name: "Aloha!",
		Config: PoolConfig{
			HealthzEvery:   "Saturn",
			HealthzTimeout: "Jupiter",
			RequestTimeout: "Mars",
			Status:         "Excellent",
		},
	}

	parsed := config.ConstructPoolConfig(test)

	if parsed.HealthzEvery == 0 || parsed.HealthzTimeout == 0 || parsed.RequestTimeout == 0 ||
		!backend.IsValidStatus(parsed.Status) {
		t.Errorf("should default to sane defaults")
	}
}