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

Method GetInstance

ring/ring.go:1258–1273  ·  view source on GitHub ↗

GetInstance return the InstanceDesc for the given instanceID or an error if the instance doesn't exist in the ring. The returned InstanceDesc is NOT a deep copy, so the caller should never modify it.

(instanceID string)

Source from the content-addressed store, hash-verified

1256// if the instance doesn't exist in the ring. The returned InstanceDesc is NOT a
1257// deep copy, so the caller should never modify it.
1258func (r *Ring) GetInstance(instanceID string) (doNotModify InstanceDesc, _ error) {
1259 r.mtx.RLock()
1260 defer r.mtx.RUnlock()
1261
1262 instances := r.ringDesc.GetIngesters()
1263 if instances == nil {
1264 return InstanceDesc{}, ErrInstanceNotFound
1265 }
1266
1267 instance, ok := instances[instanceID]
1268 if !ok {
1269 return InstanceDesc{}, ErrInstanceNotFound
1270 }
1271
1272 return instance, nil
1273}
1274
1275// GetInstanceState returns the current state of an instance or an error if the
1276// instance does not exist in the ring.

Callers 1

GetInstanceStateMethod · 0.95

Calls 1

GetIngestersMethod · 0.80

Tested by

no test coverage detected