gitee.com/h79/goutils@v1.22.10/discovery/watch/watch.go (about)

     1  package watch
     2  
     3  type Key interface {
     4  	ToKey() string
     5  	ToMap() map[string]interface{} // for consul
     6  }
     7  
     8  type Watcher interface {
     9  	Watch(key Key) (Chan, error)
    10  	Changed(cmd Changed)
    11  	Stop() error
    12  }
    13  
    14  type Chan chan Changed
    15  
    16  type Changed struct {
    17  	D   interface{}
    18  	Cmd int
    19  }
    20  
    21  func NewChanged(data interface{}, cmd int) Changed {
    22  	return Changed{
    23  		D:   data,
    24  		Cmd: cmd,
    25  	}
    26  }
    27  
    28  // Cmd=
    29  const (
    30  	Delete = 1
    31  	Put    = 2
    32  )