MCPcopy Create free account
hub / github.com/cortexproject/cortex / Lifecycler

Struct Lifecycler

pkg/ring/lifecycler.go:117–164  ·  view source on GitHub ↗

Lifecycler is responsible for managing the lifecycle of entries in the ring.

Source from the content-addressed store, hash-verified

115
116// Lifecycler is responsible for managing the lifecycle of entries in the ring.
117type Lifecycler struct {
118 *services.BasicService
119
120 cfg LifecyclerConfig
121 flushTransferer FlushTransferer
122 KVStore kv.Client
123 delegate LifecyclerDelegate
124
125 actorChan chan func()
126 autojoinChan chan struct{}
127
128 // These values are initialised at startup, and never change
129 ID string
130 Addr string
131 RingName string
132 RingKey string
133 Zone string
134
135 // Whether to flush if transfer fails on shutdown.
136 flushOnShutdown *atomic.Bool
137 unregisterOnShutdown *atomic.Bool
138
139 // Whether to auto join on ring on startup. If set to false, Join should be called.
140 autoJoinOnStartup bool
141
142 // We need to remember the ingester state, tokens and registered timestamp just in case the KV store
143 // goes away and comes back empty. The state changes during lifecycle of instance.
144 stateMtx sync.RWMutex
145 state InstanceState
146 tokenFile *TokenFile
147 registeredAt time.Time
148
149 // Controls the ready-reporting
150 readyLock sync.Mutex
151 ready bool
152 readySince time.Time
153
154 // Keeps stats updated at every heartbeat period
155 countersLock sync.RWMutex
156 healthyInstancesCount int
157 zonesCount int
158 zones []string
159
160 lifecyclerMetrics *LifecyclerMetrics
161 logger log.Logger
162
163 tg TokenGenerator
164}
165
166func NewLifecyclerWithDelegate(
167 cfg LifecyclerConfig,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected