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

Method updateRing

ring/partition_ring_editor.go:47–59  ·  view source on GitHub ↗
(ctx context.Context, update func(ring *PartitionRingDesc) (bool, error))

Source from the content-addressed store, hash-verified

45}
46
47func (l *PartitionRingEditor) updateRing(ctx context.Context, update func(ring *PartitionRingDesc) (bool, error)) error {
48 return l.store.CAS(ctx, l.ringKey, func(in interface{}) (out interface{}, retry bool, err error) {
49 ringDesc := GetOrCreatePartitionRingDesc(in)
50
51 if changed, err := update(ringDesc); err != nil {
52 return nil, false, err
53 } else if !changed {
54 return nil, false, nil
55 }
56
57 return ringDesc, true, nil
58 })
59}
60
61func changePartitionState(ring *PartitionRingDesc, partitionID int32, toState PartitionState) (changed bool, _ error) {
62 partition, exists := ring.Partitions[partitionID]

Callers 3

ChangePartitionStateMethod · 0.95

Calls 2

CASMethod · 0.65

Tested by

no test coverage detected