(mappings []mapping)
| 1655 | } |
| 1656 | |
| 1657 | func (h *heartbeats) filter(mappings []mapping) []mapping { |
| 1658 | out := make([]mapping, 0, len(mappings)) |
| 1659 | h.lock.RLock() |
| 1660 | defer h.lock.RUnlock() |
| 1661 | for _, m := range mappings { |
| 1662 | ok := m.coordinator == h.self |
| 1663 | if !ok { |
| 1664 | _, ok = h.coordinators[m.coordinator] |
| 1665 | if !ok { |
| 1666 | // If a mapping exists to a coordinator lost to heartbeats, |
| 1667 | // still add the mapping as LOST. If a coordinator misses |
| 1668 | // heartbeats but a client is still connected to it, this may be |
| 1669 | // the only mapping available for it. Newer mappings will take |
| 1670 | // precedence. |
| 1671 | m.kind = proto.CoordinateResponse_PeerUpdate_LOST |
| 1672 | } |
| 1673 | } |
| 1674 | |
| 1675 | out = append(out, m) |
| 1676 | } |
| 1677 | return out |
| 1678 | } |
| 1679 | |
| 1680 | func (h *heartbeats) subscribe() { |
| 1681 | defer h.wg.Done() |
no outgoing calls