MCPcopy Index your code
hub / github.com/cortexproject/cortex / New

Function New

pkg/util/runtimeconfig/manager.go:71–96  ·  view source on GitHub ↗

New creates an instance of Manager and starts reload config loop based on config

(cfg Config, registerer prometheus.Registerer, logger log.Logger, factory BucketClientFactory)

Source from the content-addressed store, hash-verified

69
70// New creates an instance of Manager and starts reload config loop based on config
71func New(cfg Config, registerer prometheus.Registerer, logger log.Logger, factory BucketClientFactory) (*Manager, error) {
72 if cfg.LoadPath == "" {
73 return nil, errors.New("LoadPath is empty")
74 }
75
76 if cfg.StorageConfig.Backend == "" {
77 return nil, errors.New("Backend should not be explicitly empty")
78 }
79
80 mgr := Manager{
81 cfg: cfg,
82 configLoadSuccess: promauto.With(registerer).NewGauge(prometheus.GaugeOpts{
83 Name: "runtime_config_last_reload_successful",
84 Help: "Whether the last runtime-config reload attempt was successful.",
85 }),
86 configHash: promauto.With(registerer).NewGaugeVec(prometheus.GaugeOpts{
87 Name: "runtime_config_hash",
88 Help: "Hash of the currently active runtime config file.",
89 }, []string{"sha256"}),
90 logger: logger,
91 bucketClientFactory: factory,
92 }
93
94 mgr.Service = services.NewBasicService(mgr.starting, mgr.loop, mgr.stopping)
95 return &mgr, nil
96}
97
98func (om *Manager) starting(ctx context.Context) error {
99 if om.cfg.LoadPath == "" {

Calls 1

NewBasicServiceFunction · 0.92