gitee.com/woood2/luca@v1.0.4/cmd/consumer/internal/alarm/watcher.go (about)

     1  package alarm
     2  
     3  type Watcher interface {
     4  	Run(queue chan *Alarm)
     5  }
     6  
     7  type FuncWatcher func(queue chan *Alarm)
     8  
     9  func(f FuncWatcher) Run(queue chan *Alarm) {
    10  	f(queue)
    11  }
    12  
    13  func Watch(w Watcher) {
    14  	go w.Run(alarmQueue)
    15  }
    16  
    17  func WatchFunc(f func(queue chan *Alarm)){
    18  	w:= FuncWatcher(f)
    19  	Watch(w)
    20  }