register: watcher fixes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-12-28 14:51:01 +03:00 committed by Evstigneev Denis
parent b36666d802
commit 6d92c4da55

View File

@ -15,31 +15,31 @@ type Watcher interface {
// the watcher. Actions can be create, update, delete // the watcher. Actions can be create, update, delete
type Result struct { type Result struct {
// Service holds register service // Service holds register service
Service *Service Service *Service `json:"service,omitempty"`
// Action holds the action // Action holds the action
Action string Action EventType `json:"action,omitempty"`
} }
// EventType defines register event type // EventType defines register event type
type EventType int type EventType int
const ( const (
// Create is emitted when a new service is registered // EventCreate is emitted when a new service is registered
Create EventType = iota EventCreate EventType = iota
// Delete is emitted when an existing service is deregistered // EventDelete is emitted when an existing service is deregistered
Delete EventDelete
// Update is emitted when an existing service is updated // EventUpdate is emitted when an existing service is updated
Update EventUpdate
) )
// String returns human readable event type // String returns human readable event type
func (t EventType) String() string { func (t EventType) String() string {
switch t { switch t {
case Create: case EventCreate:
return "create" return "create"
case Delete: case EventDelete:
return "delete" return "delete"
case Update: case EventUpdate:
return "update" return "update"
default: default:
return "unknown" return "unknown"
@ -49,11 +49,11 @@ func (t EventType) String() string {
// Event is register event // Event is register event
type Event struct { type Event struct {
// Timestamp is event timestamp // Timestamp is event timestamp
Timestamp time.Time Timestamp time.Time `json:"timestamp,omitempty"`
// Service is register service // Service is register service
Service *Service Service *Service `json:"service,omitempty"`
// ID is register id // ID is register id
ID string ID string `json:"id,omitempty"`
// Type defines type of event // Type defines type of event
Type EventType Type EventType `json:"type,omitempty"`
} }