gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/registry/watcher.go (about) 1 package registry 2 3 import "time" 4 5 // Watcher is an interface that returns updates 6 // about services within the registry. 7 type Watcher interface { 8 // Next is a blocking call 9 Next() (*Result, error) 10 Stop() 11 } 12 13 // Result is returned by a call to Next on 14 // the watcher. Actions can be create, update, delete 15 type Result struct { 16 Action string 17 Service *Service 18 } 19 20 // EventType defines registry event type 21 type EventType int 22 23 const ( 24 // Create is emitted when a new service is registered 25 Create EventType = iota 26 // Delete is emitted when an existing service is deregsitered 27 Delete 28 // Update is emitted when an existing servicec is updated 29 Update 30 ) 31 32 // String returns human readable event type 33 func (t EventType) String() string { 34 switch t { 35 case Create: 36 return "create" 37 case Delete: 38 return "delete" 39 case Update: 40 return "update" 41 default: 42 return "unknown" 43 } 44 } 45 46 // Event is registry event 47 type Event struct { 48 // Id is registry id 49 Id string 50 // Type defines type of event 51 Type EventType 52 // Timestamp is event timestamp 53 Timestamp time.Time 54 // Service is registry service 55 Service *Service 56 }