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

Struct Ring

pkg/ring/ring.go:179–219  ·  view source on GitHub ↗

Ring holds the information about the members of the consistent hash ring.

Source from the content-addressed store, hash-verified

177
178// Ring holds the information about the members of the consistent hash ring.
179type Ring struct {
180 services.Service
181
182 key string
183 cfg Config
184 KVClient kv.Client
185 strategy ReplicationStrategy
186
187 mtx sync.RWMutex
188 ringDesc *Desc
189 ringTokens []uint32
190 ringTokensByZone map[string][]uint32
191
192 // Maps a token with the information of the instance holding it. This map is immutable and
193 // cannot be chanced in place because it's shared "as is" between subrings (the only way to
194 // change it is to create a new one and replace it).
195 ringInstanceByToken map[uint32]instanceInfo
196
197 ringInstanceIdByAddr map[string]string
198
199 // When did a set of instances change the last time (instance changing state or heartbeat is ignored for this timestamp).
200 lastTopologyChange time.Time
201
202 // List of zones for which there's at least 1 instance in the ring. This list is guaranteed
203 // to be sorted alphabetically.
204 ringZones []string
205 previousRingZones []string
206
207 // Cache of shuffle-sharded subrings per identifier. Invalidated when topology changes.
208 // If set to nil, no caching is done (used by tests, and subrings).
209 shuffledSubringCache map[subringCacheKey]*Ring
210
211 memberOwnershipGaugeVec *prometheus.GaugeVec
212 numMembersGaugeVec *prometheus.GaugeVec
213 totalTokensGauge prometheus.Gauge
214 numTokensGaugeVec *prometheus.GaugeVec
215 oldestTimestampGaugeVec *prometheus.GaugeVec
216 reportedOwners map[string]struct{}
217
218 logger log.Logger
219}
220
221type subringCacheKey struct {
222 identifier string

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected