Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( //DefaultTimeout timeout for GetServices DefaultTimeout = 100 * time.Millisecond //DefaultRegisterInterval time between 2 registration DefaultRegisterInterval = 20 * time.Second //DefaultCheckDueInterval time between 2 checks DefaultCheckDueInterval = 200 * time.Millisecond //DefaultMainTopic default message base. All topics will start with this message DefaultMainTopic string //DefaultDueDurationFactor service expire when currentTime > lastRegisteredTime + registerInternal * dueDrationFactor DefaultDueDurationFactor = float32(1.5) )
View Source
var ( //ErrNotFound when no service found ErrNotFound = errors.New("No service found") )
Functions ¶
Types ¶
type Filter ¶
Filter used for filtering service do not return nil
func LocalhostFilter ¶
func LocalhostFilter() Filter
LocalhostFilter return true if hostname is equals to service host
type Option ¶
type Option func(opts *Options)
Option option func
func RegisterInterval ¶
RegisterInterval time between 2 register publish
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options all configurable option
type Pong ¶
type Pong struct {
Service
Timestamps *Timestamps `json:"t,omitempty"`
}
Pong response to ping
type Registry ¶
type Registry interface {
Register(s Service) (FnUnregister, error)
GetServices(name string) ([]Service, error)
GetService(name string, filters ...Filter) (*Service, error)
Observe(serviceName string) error
Close() error
}
Registry Register, Unregister
type Service ¶
type Service struct {
//Network tcp/unix/tpc6
Network string `json:"net,omitempty"`
//Bind address
Address string `json:"add,omitempty"`
//URL base used for communicate with this service
URL string `json:"url,omitempty"`
//Name service name
Name string `json:"name,omitempty"`
//Version semver version
Version string `json:"v,omitempty"`
//Host
Host string `json:"h,omitempty"`
// contains filtered or unexported fields
}
Service service struct
type Timestamps ¶
type Timestamps struct {
//date registered in nanoseconds (unix timestamp)
Registered int64
//expiration duration in milliseconds
Duration int
}
Timestamps define registered datetime and expiration duration
Click to show internal directories.
Click to hide internal directories.