func match(v *constrainedValue, filters map[Filter]interface{}) bool {
	if len(v.Constraints) != len(filters) {
		return false
	}
	for filter, filterValue := range filters {
		if v.Constraints[filter.String()] != filterValue {
			return false
		}
	}
	return true
}
match will return true if the constraints matches the filters exactly
package dynamicconfig
import (
	"errors"
	"fmt"
	"strings"
	"sync/atomic"
	"time"
	"go.temporal.io/server/common/primitives/timestamp"
)
var _ Client = (*basicClient)(nil)
type configValueMap map[string][]*constrainedValue
type constrainedValue struct {
	Value       interface{}
	Constraints map[string]interface{}
}
type basicClient struct {
	values atomic.Value  
}
func newBasicClient() *basicClient {
	bc := &basicClient{}
	bc.values.Store(configValueMap{})
	return bc
}
func (bc *basicClient) GetValue(
	name Key,
	defaultValue interface{},
) (interface{}, error) {
	return bc.getValueWithFilters(name, nil, defaultValue)
}
func (bc *basicClient) GetValueWithFilters(
	name Key,
	filters map[Filter]interface{},
	defaultValue interface{},
) (interface{}, error) {
	return bc.getValueWithFilters(name, filters, defaultValue)
}
func (bc *basicClient) GetIntValue(
	name Key,
	filters map[Filter]interface{},
	defaultValue int,
) (int, error) {
	val, err := bc.getValueWithFilters(name, filters, defaultValue)
	if err != nil {
		return defaultValue, err
	}
	if intVal, ok := val.(int); ok {
		return intVal, nil
	}
	return defaultValue, errors.New("value type is not int")
}
func (bc *basicClient) GetFloatValue(
	name Key,
	filters map[Filter]interface{},
	defaultValue float64,
) (float64, error) {
	val, err := bc.getValueWithFilters(name, filters, defaultValue)
	if err != nil {
		return defaultValue, err
	}
	if floatVal, ok := val.(float64); ok {
		return floatVal, nil
	} else if intVal, ok := val.(int); ok {
		return float64(intVal), nil
	}
	return defaultValue, errors.New("value type is not float64")
}
func (bc *basicClient) GetBoolValue(
	name Key,
	filters map[Filter]interface{},
	defaultValue bool,
) (bool, error) {
	val, err := bc.getValueWithFilters(name, filters, defaultValue)
	if err != nil {
		return defaultValue, err
	}
	if boolVal, ok := val.(bool); ok {
		return boolVal, nil
	}
	return defaultValue, errors.New("value type is not bool")
}
func (bc *basicClient) GetStringValue(
	name Key,
	filters map[Filter]interface{},
	defaultValue string,
) (string, error) {
	val, err := bc.getValueWithFilters(name, filters, defaultValue)
	if err != nil {
		return defaultValue, err
	}
	if stringVal, ok := val.(string); ok {
		return stringVal, nil
	}
	return defaultValue, errors.New("value type is not string")
}
func (bc *basicClient) GetMapValue(
	name Key,
	filters map[Filter]interface{},
	defaultValue map[string]interface{},
) (map[string]interface{}, error) {
	val, err := bc.getValueWithFilters(name, filters, defaultValue)
	if err != nil {
		return defaultValue, err
	}
	if mapVal, ok := val.(map[string]interface{}); ok {
		return mapVal, nil
	}
	return defaultValue, errors.New("value type is not map")
}
func (bc *basicClient) GetDurationValue(
	name Key, filters map[Filter]interface{}, defaultValue time.Duration,
) (time.Duration, error) {
	val, err := bc.getValueWithFilters(name, filters, defaultValue)
	if err != nil {
		return defaultValue, err
	}
	switch v := val.(type) {
	case time.Duration:
		return v, nil
	case string:
		{
			d, err := timestamp.ParseDurationDefaultDays(v)
			if err != nil {
				return defaultValue, fmt.Errorf("failed to parse duration: %v", err)
			}
			return d, nil
		}
	}
	return defaultValue, errors.New("value not convertible to Duration")
}
func (bc *basicClient) getValueWithFilters(
	key Key,
	filters map[Filter]interface{},
	defaultValue interface{},
) (interface{}, error) {
	keyName := strings.ToLower(Keys[key])
	values := bc.values.Load().(configValueMap)
	found := false
	for _, constrainedValue := range values[keyName] {
		if len(constrainedValue.Constraints) == 0 {
			defaultValue = constrainedValue.Value
			found = true
			continue
		}
		if match(constrainedValue, filters) {
			return constrainedValue.Value, nil
		}
	}
	if !found {
		return defaultValue, errors.New("unable to find key")
	}
	return defaultValue, nil
}