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

Method RemoveGroups

pkg/utils/redis/sentinel.go:614–646  ·  view source on GitHub ↗
(sentinels []string, timeout time.Duration, groups map[int]bool)

Source from the content-addressed store, hash-verified

612}
613
614func (s *Sentinel) RemoveGroups(sentinels []string, timeout time.Duration, groups map[int]bool) error {
615 cntx, cancel := context.WithTimeout(s.Context, timeout)
616 defer cancel()
617
618 timeout += time.Second * 5
619 results := make(chan error, len(sentinels))
620
621 for i := range sentinels {
622 go func(sentinel string) {
623 err := s.removeGroupsDispatch(cntx, sentinel, timeout, groups)
624 if err != nil {
625 s.errorf(err, "sentinel-[%s] remove failed", sentinel)
626 }
627 results <- err
628 }(sentinels[i])
629 }
630
631 var last error
632 for range sentinels {
633 select {
634 case <-cntx.Done():
635 if last != nil {
636 return last
637 }
638 return errors.Trace(cntx.Err())
639 case err := <-results:
640 if err != nil {
641 last = err
642 }
643 }
644 }
645 return last
646}
647
648func (s *Sentinel) removeGroupsAllDispatch(ctx context.Context, sentinel string, timeout time.Duration) error {
649 var err = s.dispatch(ctx, sentinel, timeout, func(c *Client) error {

Callers 1

GroupPromoteServerMethod · 0.95

Calls 3

removeGroupsDispatchMethod · 0.95
errorfMethod · 0.95
DoneMethod · 0.80

Tested by

no test coverage detected