Add registry event to registry package
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package registry
|
||||
|
||||
import "time"
|
||||
|
||||
// Watcher is an interface that returns updates
|
||||
// about services within the registry.
|
||||
type Watcher interface {
|
||||
@@ -14,3 +16,41 @@ type Result struct {
|
||||
Action string
|
||||
Service *Service
|
||||
}
|
||||
|
||||
// EventType defines registry event type
|
||||
type EventType int
|
||||
|
||||
const (
|
||||
// Create is emitted when a new service is registered
|
||||
Create EventType = iota
|
||||
// Delete is emitted when an existing service is deregsitered
|
||||
Delete
|
||||
// Update is emitted when an existing servicec is updated
|
||||
Update
|
||||
)
|
||||
|
||||
// String returns human readable event type
|
||||
func (t EventType) String() string {
|
||||
switch t {
|
||||
case Create:
|
||||
return "create"
|
||||
case Delete:
|
||||
return "delete"
|
||||
case Update:
|
||||
return "update"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// Event is registry event
|
||||
type Event struct {
|
||||
// Id is registry id
|
||||
Id string
|
||||
// Type defines type of event
|
||||
Type EventType
|
||||
// Timestamp is event timestamp
|
||||
Timestamp time.Time
|
||||
// Service is registry service
|
||||
Service *Service
|
||||
}
|
||||
|
Reference in New Issue
Block a user