(sentinels []string, timeout time.Duration, groups map[int]bool)
| 612 | } |
| 613 | |
| 614 | func (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 | |
| 648 | func (s *Sentinel) removeGroupsAllDispatch(ctx context.Context, sentinel string, timeout time.Duration) error { |
| 649 | var err = s.dispatch(ctx, sentinel, timeout, func(c *Client) error { |
no test coverage detected