Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func (n *network) Run(ctx context.Context) {
- wg := sync.WaitGroup{}
- log.Info("Watching for new subnet leases")
- evts := make(chan []subnet.Event)
- wg.Add(1)
- go func() {
- subnet.WatchLeases(ctx, n.sm, n.lease, evts)
- wg.Done()
- }()
- // Store a list of routes, initialized to capacity of 10.
- n.rl = make([]netlink.Route, 0, 10)
- wg.Add(1)
- // Start a goroutine which periodically checks that the right routes are created
- go func() {
- n.routeCheck(ctx)
- wg.Done()
- }()
- defer wg.Wait()
- for {
- select {
- case evtBatch := <-evts:
- n.handleSubnetEvents(evtBatch)
- case <-ctx.Done():
- return
- }
- }
- }
Add Comment
Please, Sign In to add comment