cluster

package
v0.0.0-...-7a25296 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinServiceName

func JoinServiceName(names ...string) string

func LocalIP

func LocalIP() (net.IP, error)

Types

type Cluster

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

func New

func New(ctx context.Context, logger *zap.Logger, node Node, c Configuration) (*Cluster, error)

func (*Cluster) Endpoints

func (s *Cluster) Endpoints() ([]endpoint.Endpoint, error)

func (*Cluster) Local

func (s *Cluster) Local() Node

func (*Cluster) Node

func (s *Cluster) Node(id string) (Node, bool)

func (*Cluster) Nodes

func (s *Cluster) Nodes() []Node

func (*Cluster) ServiceEndpoints

func (s *Cluster) ServiceEndpoints(name string) ([]endpoint.Endpoint, error)

func (*Cluster) Services

func (s *Cluster) Services() []Node

func (*Cluster) Shutdown

func (s *Cluster) Shutdown()

type Configuration

type Configuration struct {
	Name           string            `json:"name" yaml:"name" usage:"Cluster name"`
	IP             string            `json:"ip" yaml:"ip" usage:"Cluster ip"`
	Prefix         string            `json:"prefex" yaml:"prefix" usage:"prefix"`
	Port           int               `` /* 154-byte string literal not displayed */
	Address        string            `` /* 156-byte string literal not displayed */
	Protocol       string            `` /* 198-byte string literal not displayed */
	ServiceName    string            `yaml:"service_name" json:"service_name" usage:"Service name."`
	ServiceDomain  string            `yaml:"service_domain" json:"service_domain" usage:"Service domain."`
	SSLCertificate string            `` /* 192-byte string literal not displayed */
	SSLPrivateKey  string            `` /* 192-byte string literal not displayed */
	Etcd           EtcdConfiguration `json:"etcd" yaml:"etcd" usage:"Etcd settings"`
}

func NewConfiguration

func NewConfiguration() Configuration

func (Configuration) Check

func (c Configuration) Check() error

type EtcdConfiguration

type EtcdConfiguration struct {
	Endpoints         []string `json:"endpoints" yaml:"endpoints" usage:"Etcd address a list of URLs."`
	DialTimeout       int      `json:"dial_timeout" yaml:"dial_timeout" usage:"The timeout for failing to establish a connection."`
	DialKeepAliveTime int      `` /* 138-byte string literal not displayed */
	Username          string   `json:"username" yaml:"username" usage:"A user name for authentication"`
	Password          string   `json:"password" yaml:"password" usage:"A password for authentication"`
	Cert              string   `json:"cert" yaml:"cert" usage:"The client secure credentials"`
	Key               string   `json:"key" yaml:"key" usage:"The client secure credentials"`
	CACert            string   `json:"ca_cert" yaml:"ca_cert" usage:"The client secure credentials"`
}

type Node

type Node interface {
	// 获取节点唯一编号
	ID() string

	// 获取节点所支持的协议
	Protocol() Protocol

	// 节点服务名称
	Service() string

	// 是否为子服务
	Sub() bool

	// 获取节点的地址以及服务商品
	Address() string

	// 获取节点中附加的参数信息
	Value(k string) (string, bool)

	// 设置节点的附加信息
	SetValue(k, v string)

	// 编码节点信息
	Marshal() (string, error)

	// 解码节点信息
	Unmarshal(s string) error
}

Node 节点信息

type NodeLocal

type NodeLocal struct {
	Id           string   `json:"id"`
	Name         string   `json:"name"`
	Addr         string   `json:"address"`
	ProtocolName Protocol `json:"protocol"`
	IsSub        bool
	Values       map[string]string
}

func NewNode

func NewNode(id string, protocol Protocol, address string) *NodeLocal

func NewSubNode

func NewSubNode(id, name string, protocol Protocol, address string) *NodeLocal

func (NodeLocal) Address

func (n NodeLocal) Address() string

func (NodeLocal) ID

func (n NodeLocal) ID() string

func (*NodeLocal) Marshal

func (n *NodeLocal) Marshal() (string, error)

func (NodeLocal) Protocol

func (n NodeLocal) Protocol() Protocol

func (NodeLocal) Service

func (n NodeLocal) Service() string

func (*NodeLocal) SetValue

func (n *NodeLocal) SetValue(k, v string)

func (NodeLocal) Sub

func (n NodeLocal) Sub() bool

func (*NodeLocal) Unmarshal

func (n *NodeLocal) Unmarshal(data string) error

func (*NodeLocal) Value

func (n *NodeLocal) Value(k string) (string, bool)

type Protocol

type Protocol string
const (
	ProtocolHTTP Protocol = "http"
	ProtocolGRPC Protocol = "grpc"
)

Jump to

Keyboard shortcuts

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