regdis

package module
v0.0.0-...-1ae961c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2022 License: MIT Imports: 10 Imported by: 0

README

serviceRegisterAndDiscovery

service registration and discovery

Documentation

Index

Constants

View Source
const ServiceNameAndIDSeparator = "/"

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultService

type DefaultService struct {
	Name      string
	ID        string
	Namespace string
	Address   string
	Port      int
	Protocol  string
}

func (*DefaultService) DialURL

func (d *DefaultService) DialURL() string

func (*DefaultService) GetNamespace

func (d *DefaultService) GetNamespace() string

func (*DefaultService) GetProtocol

func (d *DefaultService) GetProtocol() string

func (*DefaultService) PublicAddress

func (d *DefaultService) PublicAddress() string

func (*DefaultService) PublicPort

func (d *DefaultService) PublicPort() int

func (*DefaultService) ServiceID

func (d *DefaultService) ServiceID() string

func (*DefaultService) ServiceName

func (d *DefaultService) ServiceName() string

func (*DefaultService) String

func (d *DefaultService) String() string

type RegistrationAndDiscovery

type RegistrationAndDiscovery interface {
	Register(ser Service) error   //向注册中心注册服务
	Deregister(ser Service) error //从注册中心取消注册

	Find(serviceName string) ([]Service, error)                   //根据服务名称从注册中心查找服务
	Subscribe(serviceName string, callback ServiceCallback) error //根据服务名订阅服务,订阅后有变动会回调
	Unsubscribe(serviceName string) error                         //取消订阅某类服务
}

func NewEtcdRegistrationDiscovery

func NewEtcdRegistrationDiscovery(endpoints []string, userName, password, savePath string, findDisable bool, timeOut time.Duration) (RegistrationAndDiscovery, error)

type Service

type Service interface {
	GetNamespace() string
	ServiceName() string
	ServiceID() string

	PublicAddress() string
	PublicPort() int
	DialURL() string
	GetProtocol() string
	String() string
}

func NewService

func NewService(namespace, name, id, protocol, address string, port int) Service

func ParseServiceFromStr

func ParseServiceFromStr(serviceStr string) (Service, error)

type ServiceCallback

type ServiceCallback func([]Service)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL