meta

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleDiscover = "barid.module.discover" // 服务发现
	ModuleElector  = "barid.module.elector"  // 服务选举
	ModuleBalancer = "barid.module.balancer" // 负载均衡
	ModuleLink     = "barid.module.link"     // 链路缓存
	ModuleMonitor  = "barid.module.monitor"  // 服务监控
	ModulePubsub   = "barid.module.pubsub"   // 发布订阅
	ModuleClient   = "barid.module.client"   // rpc客户端
	ModuleServer   = "barid.module.server"   // rpc服务端
	ModuleTracer   = "braid.module.tracer"   // 链路追踪
)
View Source
const (
	// 服务发现 - 有服务加入或退出
	TopicDiscoverServiceUpdate = "braid.topic.discover.service_update"
	// 服务发现 - 有新的节点加入服务
	TopicDiscoverServiceNodeAdd = "braid.topic.discover.service_node_add"
	// 服务发现 - 有节点退出服务
	TopicDiscoverServiceNodeRmv = "braid.topic.discover.service_node_rmv"
	// 服务发现 - 有节点信息更新
	TopicDiscoverServiceNodeUpdate = "braid.topic.discover.service_node_update"

	// 链路缓存 - 统计在中连接的总数
	TopicLinkcacheLinkNumber = "braid.topic.linkcache.service_link_number"
	// 链路缓存 - 有用户断开(下线,不再需要持有链路信息
	TopicLinkcacheUnlink = "braid.topic.linkcache.unlink"

	// 选举 - 选举状态变更
	TopicElectionChangeState = "braid.topic.election.change_state"
)
View Source
const (
	// Wait 表示此进程当前处于初始化阶段,还没有具体的选举信息
	EWait int32 = 0 + iota
	// Slave 表示此进程当前处于 从节点 状态,此状态下,elector 会不断进行重试,试图变成新的 主节点(当主节点宕机或退出时
	ESlave
	// Master 表示当前进程正处于 主节点 状态;
	EMaster
)

Variables

This section is empty.

Functions

This section is empty.

Types

type LinkNumMsg

type LinkNumMsg struct {
	ID  string
	Num int
}

LinkNumMsg msg struct

func DecodeNumMsg

func DecodeNumMsg(msg *Message) LinkNumMsg

DecodeLinkNumMsg decode linknum msg

type Message

type Message struct {
	Body []byte
	// contains filtered or unexported fields
}

Message 消息体

func CreateMessage

func CreateMessage(id string, body []byte) *Message

func EncodeNumMsg

func EncodeNumMsg(id string, num int) *Message

EncodeLinkNumMsg encode linknum msg

func EncodeStateChangeMsg

func EncodeStateChangeMsg(state int32, id string) *Message

EncodeStateChangeMsg encode

func EncodeUpdateMsg

func EncodeUpdateMsg(event string, nod Node) *Message

func (*Message) ID

func (msg *Message) ID() string

func (*Message) Timestamp

func (msg *Message) Timestamp() int64

type Node

type Node struct {
	ID   string
	Name string

	Address string
	Port    int

	Metadata map[string]interface{}
}

Node 发现节点结构

func (*Node) GetWidget

func (n *Node) GetWidget() int

func (*Node) SetWidget

func (n *Node) SetWidget(widget int)

type Service

type Service struct {
	Info ServiceInfo

	Nodes []Node
	Tags  []string
}

type ServiceInfo

type ServiceInfo struct {
	ID   string
	Name string
}

type StateChangeMsg

type StateChangeMsg struct {
	State int32
	ID    string
}

StateChangeMsg become master msg

func DecodeStateChangeMsg

func DecodeStateChangeMsg(msg *Message) StateChangeMsg

DecodeStateChangeMsg decode

type UpdateMsg

type UpdateMsg struct {
	Nod   Node
	Event string
}

func DecodeUpdateMsg

func DecodeUpdateMsg(msg *Message) UpdateMsg

Jump to

Keyboard shortcuts

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