Guest User

Untitled

a guest
Nov 17th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. func (n *network) Run(ctx context.Context) {
  2. wg := sync.WaitGroup{}
  3.  
  4. log.Info("Watching for new subnet leases")
  5. evts := make(chan []subnet.Event)
  6. wg.Add(1)
  7. go func() {
  8. subnet.WatchLeases(ctx, n.sm, n.lease, evts)
  9. wg.Done()
  10. }()
  11.  
  12. // Store a list of routes, initialized to capacity of 10.
  13. n.rl = make([]netlink.Route, 0, 10)
  14. wg.Add(1)
  15.  
  16. // Start a goroutine which periodically checks that the right routes are created
  17. go func() {
  18. n.routeCheck(ctx)
  19. wg.Done()
  20. }()
  21.  
  22. defer wg.Wait()
  23.  
  24. for {
  25. select {
  26. case evtBatch := <-evts:
  27. n.handleSubnetEvents(evtBatch)
  28.  
  29. case <-ctx.Done():
  30. return
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment