NewClient creates a new Client (consul, etcd or inmemory) based on the config, encodes and decodes data for storage using the codec.
(cfg Config, codec codec.Codec, reg prometheus.Registerer, logger log.Logger)
| 127 | // NewClient creates a new Client (consul, etcd or inmemory) based on the config, |
| 128 | // encodes and decodes data for storage using the codec. |
| 129 | func NewClient(cfg Config, codec codec.Codec, reg prometheus.Registerer, logger log.Logger) (Client, error) { |
| 130 | if cfg.Mock != nil { |
| 131 | return cfg.Mock, nil |
| 132 | } |
| 133 | |
| 134 | return createClient(cfg.Store, cfg.Prefix, cfg.StoreConfig, codec, Primary, reg, logger) |
| 135 | } |
| 136 | |
| 137 | func createClient(backend string, prefix string, cfg StoreConfig, codec codec.Codec, role role, reg prometheus.Registerer, logger log.Logger) (Client, error) { |
| 138 | var client Client |