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

Method ChangeReadOnlyState

ring/lifecycler.go:364–382  ·  view source on GitHub ↗
(ctx context.Context, readOnly bool)

Source from the content-addressed store, hash-verified

362}
363
364func (i *Lifecycler) ChangeReadOnlyState(ctx context.Context, readOnly bool) error {
365 errCh := make(chan error)
366 fn := func() {
367 prevReadOnly, _ := i.GetReadOnlyState()
368 if prevReadOnly == readOnly {
369 errCh <- nil
370 return
371 }
372
373 level.Info(i.logger).Log("msg", "changing read-only state of instance in the ring", "readOnly", readOnly, "ring", i.RingName)
374 i.setReadOnlyState(readOnly, time.Now())
375 errCh <- i.updateConsul(ctx)
376 }
377
378 if err := i.sendToLifecyclerLoop(fn); err != nil {
379 return err
380 }
381 return <-errCh
382}
383
384func (i *Lifecycler) getTokens() Tokens {
385 i.stateMtx.RLock()

Calls 5

GetReadOnlyStateMethod · 0.95
setReadOnlyStateMethod · 0.95
updateConsulMethod · 0.95
sendToLifecyclerLoopMethod · 0.95
LogMethod · 0.45