hestia

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2025 License: MIT Imports: 6 Imported by: 0

README

hestia

名字起源于希腊神话人物:赫斯提亚(Hestia)。具有以下含义:

  1. 背景‌:炉灶与家庭女神,守护家庭稳定。
  2. 寓意‌:适合服务注册的持久性和稳定性保障模块。

因此使用它,作为服务发现和注册的名字,强调服务状态的实时可见性。

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServicesNotFound = errors.New("services not found")

ErrServicesNotFound 服务列表为空

Functions

func LocalAddr

func LocalAddr() (string, error)

LocalAddr returns local ipv4 ip

func NewNetAddr

func NewNetAddr(network, address string) net.Addr

NewNetAddr creates a new NetAddr object with the network and address provided.

func Resolve

func Resolve(address string) (string, error)

Resolve returns host:port address

Types

type Discovery

type Discovery interface {
	// GetServices returns a list of instances
	// After we obtain the service instance, we can get the currently available service instance
	// from the service list according to different strategies.
	GetServices(name string) ([]*Service, error)

	// Get returns an available service instance based on the specified service selection strategy.
	// the selection strategy is RoundRobinHandler
	Get(name string, strategyHandler ...StrategyHandler) (*Service, error)

	// String returns the name of the resolver.
	String() string
}

Discovery service discovery interface

type NetAddr

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

NetAddr implements the net.Addr interface.

func (*NetAddr) Network

func (na *NetAddr) Network() string

Network implements the net.Addr interface.

func (*NetAddr) String

func (na *NetAddr) String() string

String implements the net.Addr interface.

type Registry

type Registry interface {
	// Register service instance register
	Register(s *Service) error

	// Deregister the service goes offline when the application exit
	Deregister(s *Service) error

	// String returns the name of the registry
	String() string
}

Registry is extension interface of service registry

type Service

type Service struct {
	// network name of the network (for example, "tcp", "udp")
	Network string `json:"network"`

	// 服务名字
	Name string `json:"name"`

	// 服务地址,一般来说由host:port组成
	Address string `json:"address"`

	// 命名服务的地址,例如:k8s的user.local.svc
	NamedSvcAddress string `json:"named_svc_address"`

	// 服务的唯一标识,例如uuid字符串
	InstanceID string `json:"instance_id"`

	// 当前版本
	Version string `json:"version"`

	// 创建时间
	Created string `json:"created"`

	// 服务的其他元信息
	// Metadata map[string]string{} `json:"metadata"`
	Metadata map[string]interface{} `json:"metadata"`

	// 其他标签信息
	Tags map[string]string `json:"tags"`
}

Service 服务基本信息

func RoundRobinHandler

func RoundRobinHandler(services []*Service) *Service

RoundRobinHandler returns a random service instance.

type StrategyHandler

type StrategyHandler func(services []*Service) *Service

StrategyHandler service selection strategy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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