(sentinels []string, timeout time.Duration)
| 669 | } |
| 670 | |
| 671 | func (s *Sentinel) RemoveGroupsAll(sentinels []string, timeout time.Duration) error { |
| 672 | cntx, cancel := context.WithTimeout(s.Context, timeout) |
| 673 | defer cancel() |
| 674 | |
| 675 | timeout += time.Second * 5 |
| 676 | results := make(chan error, len(sentinels)) |
| 677 | |
| 678 | for i := range sentinels { |
| 679 | go func(sentinel string) { |
| 680 | err := s.removeGroupsAllDispatch(cntx, sentinel, timeout) |
| 681 | if err != nil { |
| 682 | s.errorf(err, "sentinel-[%s] remove failed", sentinel) |
| 683 | } |
| 684 | results <- err |
| 685 | }(sentinels[i]) |
| 686 | } |
| 687 | |
| 688 | var last error |
| 689 | for range sentinels { |
| 690 | select { |
| 691 | case <-cntx.Done(): |
| 692 | if last != nil { |
| 693 | return last |
| 694 | } |
| 695 | return errors.Trace(cntx.Err()) |
| 696 | case err := <-results: |
| 697 | if err != nil { |
| 698 | last = err |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | return last |
| 703 | } |
| 704 | |
| 705 | type SentinelGroup struct { |
| 706 | Master map[string]string `json:"master"` |
no test coverage detected