discovery

package
v0.6.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDiscoveryDown = errors.New("discovery down")
)

Functions

func CheckSkill

func CheckSkill(skill string) bool

CheckSkill 检查目标技能是否符合

Types

type Attrs

type Attrs map[string]string

Attrs 属性集合

type IApp

type IApp interface {
	IAttributes
	ID() string
	Nodes() []INode
	Reset(nodes Nodes)
	NodeError(id string) error
	Close() error
}

IApp app接口

func NewApp

func NewApp(checker IHealthChecker, container IAppContainer, attrs Attrs, nodes Nodes) IApp

NewApp 创建服务发现app

type IAppContainer

type IAppContainer interface {
	Remove(id string) error
}

IAppContainer app容器接口

type IAttributes

type IAttributes interface {
	GetAttrs() Attrs
	GetAttrByName(name string) (string, bool)
}

IAttributes 属性接口

type IDiscovery

type IDiscovery interface {
	GetApp(config string) (IApp, error)
}

IDiscovery 服务发现接口

type IHealthChecker

type IHealthChecker interface {
	AddToCheck(node INode) error
	Stop() error
}

IHealthChecker 健康检查接口

type IHealthCheckerFactory

type IHealthCheckerFactory interface {
	IHealthChecker
	Agent() (IHealthChecker, error)
	Reset(conf interface{}) error
}

IHealthCheckerFactory 健康检查工厂类接口

type INode

type INode interface {
	IAttributes
	ID() string
	IP() string
	Port() int
	Scheme() string
	Addr() string
	Status() NodeStatus
	Up()
	Down()
	Leave()
}

INode 节点接口

func NewNode

func NewNode(labels map[string]string, id string, ip string, port int, scheme string) INode

NewNode 创建新节点

type INodesData

type INodesData interface {
	Get(name string) (map[string]INode, bool)
	Set(name string, nodes map[string]INode)
	Del(name string) (map[string]INode, bool)
}

type IServices

type IServices interface {
	Set(serviceName string, id string, app IApp) error
	Remove(id string) (string, int)
	Update(serviceName string, nodes Nodes) error
	AppKeys() []string
}

IServices 服务app集合接口

func NewServices

func NewServices() IServices

NewServices 创建服务发现的服务app集合

type NodeStatus

type NodeStatus int

NodeStatus 节点状态类型

const (
	//Running 节点运行中状态
	Running NodeStatus = 1
	//Down 节点不可用状态
	Down NodeStatus = 2
	//Leave 节点离开状态
	Leave NodeStatus = 3
)

type Nodes

type Nodes map[string]INode

type NodesData

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

func NewNodesData

func NewNodesData() *NodesData

func (*NodesData) Del

func (n *NodesData) Del(name string) (map[string]INode, bool)

func (*NodesData) Get

func (n *NodesData) Get(name string) (map[string]INode, bool)

func (*NodesData) Set

func (n *NodesData) Set(name string, nodes map[string]INode)

Jump to

Keyboard shortcuts

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