(ctx context.Context, update func(ring *PartitionRingDesc) (bool, error))
| 45 | } |
| 46 | |
| 47 | func (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 | |
| 61 | func changePartitionState(ring *PartitionRingDesc, partitionID int32, toState PartitionState) (changed bool, _ error) { |
| 62 | partition, exists := ring.Partitions[partitionID] |
no test coverage detected