Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
func Marshal(s *ServiceInstance) (string, error)
Types ¶
type IDiscovery ¶
type IDiscovery interface { GetService(ctx context.Context, serviceName string) ([]*ServiceInstance, error) // Watch creates a watcher according to the service name. Watch(ctx context.Context, serviceName string) (IWatcher, error) }
IDiscovery 服务发现
type IRegister ¶
type IRegister interface { Register(ctx context.Context, service *ServiceInstance) error Deregister(ctx context.Context, service *ServiceInstance) error }
IRegister 服务注册
type IWatcher ¶
type IWatcher interface { // Next returns services in the following two cases: // 1.the first time to watch and the service instance list is not empty. // 2.any service instance changes found. // if the above two conditions are not met, it will block until context deadline exceeded or canceled Next() ([]*ServiceInstance, error) // Stop close the watcher. Stop() error }
type ServiceInstance ¶
type ServiceInstance struct { Name string `json:"name"` Key string `json:"key"` Endpoint string `json:"endpoint"` }
func NewServiceInstance ¶
func NewServiceInstance(id int64, nameSpace, name, endpoint string) *ServiceInstance
func Unmarshal ¶
func Unmarshal(data []byte) (s *ServiceInstance, err error)
func (*ServiceInstance) GetServerName ¶
func (s *ServiceInstance) GetServerName() string
Click to show internal directories.
Click to hide internal directories.