code: func (s *Store) Subscribe(service string, sendCurrent bool, kinds discoverd.EventKind, ch chan *discoverd.Event) stream.Stream {
  	s.mu.Lock()
  	defer s.mu.Unlock()
  
  	// Create service subscription list if it doesn't exist yet.
  	if _, ok := s.subscribers[service]; !ok {
  		s.subscribers[service] = list.New()
  	}
  
  	// Create and add subscription.
  	sub := &subscription{
  		kinds:   kinds,
  		ch:      ch,
  		store:   s,
  		service: service,
  	}
  	sub.el = s.subscribers[service].PushBack(sub)
  
  	// Send current instances.
  	if sendCurrent && kinds.Any(discoverd.EventKindUp) {
  		for _, inst := range s.instances(service) {
  			ch <- &discoverd.Event{
  				Service:  service,
  				Kind:     discoverd.EventKindUp,
  				Instance: inst,
  			}
  			// TODO: add a timeout to sends so that clients can't slow things down too much
  		}
  	}
  
  	// Send current leader.
  	if leader := s.serviceLeader(service); sendCurrent && kinds&discoverd.EventKindLeader != 0 && leader != nil {
  		ch <- &discoverd.Event{
  			Service:  service,
  			Kind:     discoverd.EventKindLeader,
  			Instance: leader,
  		}
  	}
  
  	// Send current service meta data.
  	if meta := s.serviceMeta(service); sendCurrent && kinds.Any(discoverd.EventKindServiceMeta) && meta != nil {
  		ch <- &discoverd.Event{
  			Service:     service,
  			Kind:        discoverd.EventKindServiceMeta,
  			ServiceMeta: meta,
  		}
  	}
  
  	// Send current service.
  	if sendCurrent && kinds.Any(discoverd.EventKindCurrent) {
  		ch <- &discoverd.Event{
  			Service: service,
  			Kind:    discoverd.EventKindCurrent,
  		}
  	}
  
  	return sub
  }
docs: // Subscribe creates a subscription to events on a given service.