| 187 | } |
| 188 | |
| 189 | func setupFactories[T any](factoryBuilder map[string]func(configMap common.ConfigMap) (T, error), |
| 190 | config map[string]common.ConfigMap, |
| 191 | ) (map[string]T, error) { |
| 192 | factories := make(map[string]T) |
| 193 | for name, builder := range factoryBuilder { |
| 194 | f, err := builder(config[name]) |
| 195 | if err != nil { |
| 196 | return nil, fmt.Errorf("error creating factory [%s] %w", name, err) |
| 197 | } |
| 198 | factories[name] = f |
| 199 | } |
| 200 | return factories, nil |
| 201 | } |
| 202 | |
| 203 | func DefaultStateStoreLoader(c *StateStoreConfig) (api.StateStore, error) { |
| 204 | switch strings.ToLower(*c.Type) { |