startDistributor starts both the collector and distributor goroutines
()
| 215 | |
| 216 | // startDistributor starts both the collector and distributor goroutines |
| 217 | func (wm *watchManager) startDistributor() { |
| 218 | defer wm.cleanUpSubscribers() |
| 219 | |
| 220 | // start the victim collector goroutine |
| 221 | // it collects the victim buckets from the victim channel |
| 222 | // and handle delete bucket operation |
| 223 | wm.wg.Add(1) |
| 224 | go func() { |
| 225 | defer wm.wg.Done() |
| 226 | wm.runVictimCollector() |
| 227 | }() |
| 228 | |
| 229 | // Start the distributor goroutine (consumes from distributeChan) |
| 230 | wm.wg.Add(1) |
| 231 | go func() { |
| 232 | defer wm.wg.Done() |
| 233 | wm.runDistributor() |
| 234 | }() |
| 235 | |
| 236 | // start the collector goroutine (collects messages into batches) |
| 237 | wm.wg.Add(1) |
| 238 | go func() { |
| 239 | defer wm.wg.Done() |
| 240 | wm.runCollector() |
| 241 | }() |
| 242 | |
| 243 | wm.wg.Wait() |
| 244 | } |
| 245 | |
| 246 | // runCollector collects messages from watchChan and batches them |
| 247 | func (wm *watchManager) runCollector() { |