serviceregistry

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Global = New()

Global is the global service registry.

Functions

This section is empty.

Types

type Server

type Server struct {
	// ServiceName is required.
	ServiceName string `yaml:"serviceName"`

	// Scheme is optional if Port is not empty.
	Scheme string `yaml:"scheme"`
	// Hostname is optional if HostIP is not empty.
	Hostname string `yaml:"hostname"`
	// HostIP is optional if Hostname is not empty.
	HostIP string `yaml:"hostIP"`
	// Port is optional if Scheme is not empty
	Port uint16 `yaml:"port"`
	// Tags is optional.
	Tags []string `yaml:"tags"`
	// Weight is optional.
	Weight int `yaml:"weight"`
}

Server stands for one instance of the server.

func (*Server) URL

func (s *Server) URL() string

URL returns the url of the server.

func (*Server) Validate

func (s *Server) Validate() error

Validate validates itself.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service contains the information of all backend servers of one service.

func NewService

func NewService(name string, servers []*Server) (*Service, error)

NewService creates a Service.

func (*Service) Close

func (s *Service) Close(message string)

Close closes the service.

func (*Service) CloseMessage

func (s *Service) CloseMessage() string

CloseMessage closes the service.

func (*Service) Closed

func (s *Service) Closed() chan struct{}

Closed returns the notifying channel to post close.

func (*Service) Name

func (s *Service) Name() string

Name returns the service name.

func (*Service) Servers

func (s *Service) Servers() []*Server

Servers return the current servers.

func (*Service) Update

func (s *Service) Update(servers []*Server) error

Update updates the Service with closing the channel updated. It does nothing if servers are not changed.

func (*Service) Updated

func (s *Service) Updated() chan struct{}

Updated returns the notifying channel to post update.

type ServiceRegistry

type ServiceRegistry struct {
	// contains filtered or unexported fields
}

ServiceRegistry is the service center containing all drivers.

func New

func New() *ServiceRegistry

New creates a ServiceRegistry.

func (*ServiceRegistry) CloseRegistry

func (sg *ServiceRegistry) CloseRegistry(registryName string)

CloseRegistry deletes the registry with closing its services.

func (*ServiceRegistry) GetService

func (sg *ServiceRegistry) GetService(registryName, serviceName string) (*Service, error)

GetService gets service. NOTICE: If the registryName is empty, and there is one and only one ServiceRegistry, it uses the only one.

func (*ServiceRegistry) ReplaceServers

func (sg *ServiceRegistry) ReplaceServers(registryName string, servers []*Server)

ReplaceServers replaces all servers of the registry.

Jump to

Keyboard shortcuts

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