Matching returns a list of all cluster members for whom the given proxy Metadata matches
(id, app string, maxAge time.Duration)
| 92 | |
| 93 | // Matching returns a list of all cluster members for whom the given proxy Metadata matches |
| 94 | func (c *Cluster) Matching(id, app string, maxAge time.Duration) (list []Member) { |
| 95 | c.mu.Lock() |
| 96 | defer c.mu.Unlock() |
| 97 | |
| 98 | for k, v := range c.members { |
| 99 | if time.Since(v) > maxAge { |
| 100 | continue |
| 101 | } |
| 102 | |
| 103 | i, a := dehash(k) |
| 104 | if id != "" && id != i { |
| 105 | continue |
| 106 | } |
| 107 | if app != "" && app != a { |
| 108 | continue |
| 109 | } |
| 110 | list = append(list, Member{ |
| 111 | ID: i, |
| 112 | App: a, |
| 113 | LastActive: v, |
| 114 | }) |
| 115 | } |
| 116 | return |
| 117 | } |
| 118 | |
| 119 | // Update adds (or updates) a proxy to/in the cluster |
| 120 | func (c *Cluster) Update(id, app string) { |
no test coverage detected