Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAlreadyRegistered = errors.New("already registered") ErrServiceNotFound = errors.New("service not found") )
error define
Functions ¶
Types ¶
type Config ¶
type Config struct {
Instance *Instance `json:"instance"`
Name string `json:"name"`
HeartBeatInterval int64 `json:"heart_beat_interval"` // default 10s
MaximumRetry int `json:"maximum_retry"` // default 20
}
Config for registry
type EventHandler ¶
EventHandler of instance change
type Instance ¶
type Instance struct {
Id string `json:"id"` // uuid
Host string `json:"host"` // host
HostName string `json:"host_name"` // host name
Port int `json:"port"` // port
ServiceName string `json:"service_name"` // service name, usually use it as routing key
Meta map[string]interface{} `json:"meta"` // meta data
}
Instance of registry object
func Current ¶
func Current() *Instance
Current returns copy of current instance, if not registered return Empty Instance
func NewInstance ¶
func (*Instance) WithMetaData ¶
type Interface ¶
type Interface interface {
// Deregister deregister currentInstance
Deregister(ctx context.Context) (err error)
// GetService by service name
GetService(ctx context.Context, serviceName ...string) (service *Service, err error)
// GetServices of all
GetServices(ctx context.Context) (services map[string]*Service, err error)
// RegisterEventHandler register event handler
RegisterEventHandler(handler EventHandler)
// contains filtered or unexported methods
}
Interface abstracts registry
Click to show internal directories.
Click to hide internal directories.