MCPcopy
hub / github.com/CodisLabs/codis / SyncRemoveAction

Method SyncRemoveAction

pkg/topom/topom_group.go:477–501  ·  view source on GitHub ↗
(addr string)

Source from the content-addressed store, hash-verified

475}
476
477func (s *Topom) SyncRemoveAction(addr string) error {
478 s.mu.Lock()
479 defer s.mu.Unlock()
480 ctx, err := s.newContext()
481 if err != nil {
482 return err
483 }
484
485 g, index, err := ctx.getGroupByServer(addr)
486 if err != nil {
487 return err
488 }
489 if g.Promoting.State != models.ActionNothing {
490 return errors.Errorf("group-[%d] is promoting", g.Id)
491 }
492
493 if g.Servers[index].Action.State == models.ActionNothing {
494 return errors.Errorf("server-[%s] action doesn't exist", addr)
495 }
496 defer s.dirtyGroupCache(g.Id)
497
498 g.Servers[index].Action.Index = 0
499 g.Servers[index].Action.State = models.ActionNothing
500 return s.storeUpdateGroup(g)
501}
502
503func (s *Topom) SyncActionPrepare() (string, error) {
504 s.mu.Lock()

Callers 3

TestSyncActionFunction · 0.45
TestApiGroupFunction · 0.45

Calls 5

newContextMethod · 0.95
dirtyGroupCacheMethod · 0.95
storeUpdateGroupMethod · 0.95
getGroupByServerMethod · 0.80
ErrorfMethod · 0.80

Tested by 2

TestSyncActionFunction · 0.36
TestApiGroupFunction · 0.36