MCPcopy
hub / github.com/grafana/dskit / buildMultiClient

Function buildMultiClient

kv/client.go:194–221  ·  view source on GitHub ↗
(cfg StoreConfig, codec codec.Codec, reg prometheus.Registerer, logger log.Logger)

Source from the content-addressed store, hash-verified

192}
193
194func buildMultiClient(cfg StoreConfig, codec codec.Codec, reg prometheus.Registerer, logger log.Logger) (Client, error) {
195 if cfg.Multi.Primary == "" || cfg.Multi.Secondary == "" {
196 return nil, fmt.Errorf("primary or secondary store not set")
197 }
198 if cfg.Multi.Primary == "multi" || cfg.Multi.Secondary == "multi" {
199 return nil, fmt.Errorf("primary and secondary stores cannot be multi-stores")
200 }
201 if cfg.Multi.Primary == cfg.Multi.Secondary {
202 return nil, fmt.Errorf("primary and secondary stores must be different")
203 }
204
205 primary, err := createClient(cfg.Multi.Primary, "", cfg, codec, Primary, reg, logger)
206 if err != nil {
207 return nil, err
208 }
209
210 secondary, err := createClient(cfg.Multi.Secondary, "", cfg, codec, Secondary, reg, logger)
211 if err != nil {
212 return nil, err
213 }
214
215 clients := []kvclient{
216 {client: primary, name: cfg.Multi.Primary},
217 {client: secondary, name: cfg.Multi.Secondary},
218 }
219
220 return NewMultiClient(cfg.Multi, clients, logger, reg), nil
221}

Callers 1

createClientFunction · 0.85

Calls 3

createClientFunction · 0.85
NewMultiClientFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected