Documentation
¶
Index ¶
- Variables
- func Logger() logger.ILogger
- func Register(name string, creator func(opts ...Option) IRegistry)
- type Config
- type DeregisterConfig
- type Endpoint
- type Event
- type EventType
- type GetConfig
- type IRegistry
- type ListConfig
- type Node
- type Option
- type RegisterConfig
- type Result
- type Service
- type Value
- type WatchConfig
- type WatchOptions
- type Watcher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("service not found") // Not found error when GetService is called ErrWatcherStopped = errors.New("watcher stopped") // Watcher stopped error when watcher is stopped )
Functions ¶
Types ¶
type Config ¶
type Config struct { config.Config `field:"-"` Name string `field:"-"` // PrefixName string `field:"-"` // config prefix name/path in config file Logger logger.ILogger `field:"-"` // 实例 Context context.Context `field:"-"` LocalServices []*Service `field:"-"` // current service information Addrs []string `field:"-"` TlsConfig *tls.Config `field:"-"` Timeout time.Duration Secure bool TTL time.Duration `field:"ttl"` }
type DeregisterConfig ¶
type Endpoint ¶
type Endpoint struct { // RPC Method e.g. Greeter.Hello Name string `json:"name"` // HTTP Host e.g example.com Host []string `json:"host"` // HTTP Methods e.g GET, POST Method []string `json:"method"` // HTTP Path e.g /greeter. Expect POSIX regex Path string `json:"path"` // Description e.g what's this endpoint for Description string `json:"description"` // Stream flag Stream bool `json:"stream"` // 以下待确认 Request *Value `json:"request"` Response *Value `json:"response"` Metadata map[string]string `json:"metadata"` // API Handler e.g rpc, proxy Handler string // Body destination // "*" or "" - top level message value // "string" - inner message value Body string }
type 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 }
Event is registry event
type IRegistry ¶
type IRegistry interface { Init(...Option) error Config() *Config Register(*Service, ...Option) error // 注册 Deregister(*Service, ...Option) error // 注销 GetService(string) ([]*Service, error) ListServices() ([]*Service, error) Watcher(...WatchOptions) (Watcher, error) LocalServices() []*Service String() string }
注册中心接口
type ListConfig ¶
type Node ¶
type Node struct { Id string `json:"id"` Address string `json:"address"` Metadata map[string]string `json:"metadata"` }
微服务节点 相当于每个程序/Port一个节点
type RegisterConfig ¶
type Result ¶
Result is returned by a call to Next on the watcher. Actions can be create, update, delete
type Service ¶
type Service struct { Name string `json:"name"` Version string `json:"version"` Metadata map[string]string `json:"metadata"` Endpoints []*Endpoint `json:"endpoints"` Nodes []*Node `json:"nodes"` }
微服务
type WatchConfig ¶
type WatchOptions ¶
type WatchOptions func(*WatchConfig) error
Click to show internal directories.
Click to hide internal directories.