// TODO: subscribe to events rather than the registry itself?
324725
func (o *os) Watch(opts ...registry.WatchOption) (registry.Watcher, error) {
	var wo registry.WatchOptions
	for _, o := range opts {
		o(&wo)
	}

	req := o.opts.Client.NewRequest("go.micro.srv.discovery", "Registry.Watch", &proto2.WatchRequest{
		Service: wo.Service,
	})

	var gstream client.Streamer
	var grr error

	for _, addr := range o.next() {
		stream, err := o.opts.Client.StreamRemote(context.TODO(), addr, req)
		if err != nil {
			grr = err
			continue
		}
		gstream = stream
		break
	}

	if grr != nil {
		return nil, grr
	}

	// send empty watch request
	if err := gstream.Send(&proto2.WatchRequest{}); err != nil {
		return nil, err
	}

	wc := &watchClient{gstream}
	return &watcher{wc}, nil
}
767081
func (s *Server) EventsEnabled() bool {
	s.mu.Lock()
	defer s.mu.Unlock()
	return s.eventsEnabled()
}
724536
func (s *Subscriber) Subscribe(e Event, f interface{}) *Subscriber {
	unsubscribe := s.events.subscribe(e, f)
	s.unsuscribes = append(s.unsuscribes, unsubscribe)
	return s
}
1144738
func (ref *EventClientRef) RegisterTxStatusEvent(txID string) (fab.Registration, <-chan *fab.TxStatusEvent, error) {
	service, err := ref.get()
	if err != nil {
		return nil, nil, err
	}
	return service.RegisterTxStatusEvent(txID)
}
208133
func (es *EventSystem) subscribe(sub *subscription) *Subscription {
	es.install <- sub
	<-sub.installed
	return &Subscription{ID: sub.id, f: sub, es: es}
}
1336754
func (dis *dispatcher) RegisterListener(listenerObj core.EventListener, keys ...string) error {
	if listenerObj == nil {
		err := errors.New("nil listener")
		openlogging.GetLogger().Error("nil listener supplied:" + err.Error())
		return errors.New("nil listener")
	}

	for _, key := range keys {
		listenerList, ok := dis.listeners[key]
		if !ok {
			listenerList = make([]core.EventListener, 0)
		}

		// for duplicate registration
		for _, listener := range listenerList {
			if listener == listenerObj {
				return nil
			}
		}

		// append new listener
		listenerList = append(listenerList, listenerObj)

		// assign latest listener list
		dis.listeners[key] = listenerList
	}
	return nil
}
708591
func (c *Client) Register(event NotifyCategory) error {
	if event == ChannelEvents {
		return c.RegisterChannel(0)
	}

	_, err := c.ExecCmd(NewCmd("servernotifyregister").WithArgs(
		NewArg("event", event),
	))
	return err
}
832533
func (w *Watcher) TriggerEvent(eventType Op, file os.FileInfo) {
	w.Wait()
	if file == nil {
		file = &fileInfo{name: "triggered event", modTime: time.Now()}
	}
	w.Event <- Event{Op: eventType, Path: "-", FileInfo: file}
}
1061551
func (g *Generator) EventType(doms []proto.Domain) {
	g.hasContent = true
	g.Printf(`
// EventType is the type for CDP event names.
type EventType string

func (e EventType) String() string {
	return string(e)
}

// Event methods.
const (`)
	for _, d := range doms {
		for _, e := range d.Events {
			g.Printf("\n\t%s EventType = %q", e.EventName(d), d.Domain+"."+e.NameName)
		}
	}
	g.Printf("\n)\n")
}
499816
func (c *Client) RegisterBlockEvent(filter ...fab.BlockFilter) (fab.Registration, <-chan *fab.BlockEvent, error) {
	if !c.permitBlockEvents {
		return nil, nil, errors.New("block events are not permitted")
	}
	return c.Service.RegisterBlockEvent(filter...)
}
258114
func (s *LocalSupervisor) RegisterEventMapping(m EventMapping) {
	s.Lock()
	defer s.Unlock()

	s.eventMappings = append(s.eventMappings, m)
}
1070355
func (d *Dispatcher) Register(etype Type, callback Callback) {
	if callback == nil {
		return
	}

	d.Lock()
	defer d.Unlock()
	d.callbacks[etype] = append(d.callbacks[etype], callback)
}
742768
func (t *FixedInterval) Register(callback events.Callback) {
	t.Dispatcher.Register(t.etype, callback)
}
882366
func EventSubscriber(eventSub types.EventSubscriber) func(*wsConnection) {
	return func(wsc *wsConnection) {
		wsc.eventSub = eventSub
	}
}
863726
func (ref *EventClientRef) RegisterBlockEvent(filter ...fab.BlockFilter) (fab.Registration, <-chan *fab.BlockEvent, error) {
	service, err := ref.get()
	if err != nil {
		return nil, nil, err
	}
	return service.RegisterBlockEvent(filter...)
}
730988
func RegisterEventHook(name string, hook EventHook) {
	if name == "" {
		panic("event hook must have a name")
	}
	_, dup := eventHooks.LoadOrStore(name, hook)
	if dup {
		panic("hook named " + name + " already registered")
	}
}
57173
func (s *Instancer) Register(ch chan<- sd.Event) {
	s.cache.Register(ch)
}