code: func (r *registry) WatchSubnets(since uint64, stop chan bool) (*subnet.Response, error) {
  	for {
  		select {
  		case event, ok := <-r.events:
  			if !ok {
  				return nil, errors.New("unexpected close of discoverd event stream")
  			}
  			if event.Kind != discoverd.EventKindServiceMeta {
  				continue
  			}
  			net := &Network{}
  			if err := json.Unmarshal(event.ServiceMeta.Data, net); err != nil {
  				return nil, err
  			}
  			subnets := make(map[string][]byte)
  			for subnet, data := range net.Subnets {
  				if known, ok := knownSubnets[subnet]; ok && reflect.DeepEqual(known, data) {
  					continue
  				}
  				subnets[subnet] = []byte(*data)
  			}
  			knownSubnets = net.Subnets
  			if event.ServiceMeta.Index >= since {
  				return &subnet.Response{Subnets: subnets, Index: event.ServiceMeta.Index}, nil
  			}
  		case <-stop:
  			return nil, nil
  		}
  	}
  }
docs: // WatchSubnets waits for a service metadata event with an index greater than
  // a given value, and then returns a response.