cluster

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: BSD-3-Clause Imports: 21 Imported by: 0

README

cluster包

cluser包实现服务互联

以gate为总线的互联

TODO

以etcd为服务发现的网状互联

TODO

Documentation

Index

Constants

View Source
const (
	TimeoutSecond   = 5
	DefaultLeaseTTL = 5
)

Variables

This section is empty.

Functions

func SignAccessToken

func SignAccessToken(node choykit.NodeID, gameId, key string) string

注册签名

Types

type Backend

type Backend struct {
	Node
	qnet.RpcFactory
	// contains filtered or unexported fields
}

服务节点

func (*Backend) AddDependency

func (s *Backend) AddDependency(info *protocol.NodeInfo)

func (*Backend) DelDependency

func (s *Backend) DelDependency(etcdDown bool, node choykit.NodeID)

func (*Backend) Init

func (s *Backend) Init(ctx *choykit.ServiceContext) error

func (*Backend) IsMyDependency

func (s *Backend) IsMyDependency(node choykit.NodeID) bool

func (*Backend) NodeInfo

func (s *Backend) NodeInfo() *protocol.NodeInfo

func (*Backend) Shutdown

func (s *Backend) Shutdown()

func (*Backend) Startup

func (s *Backend) Startup() error

type EtcdDiscovery

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

func NewEtcdDiscovery

func NewEtcdDiscovery(opts *choykit.Options, sink ServiceSinker) *EtcdDiscovery

func (*EtcdDiscovery) Close

func (d *EtcdDiscovery) Close()

func (*EtcdDiscovery) Start

func (d *EtcdDiscovery) Start() error

type Node

type Node struct {
	choykit.Executor
	// contains filtered or unexported fields
}

节点

func (*Node) AddMessageHandler

func (s *Node) AddMessageHandler(isPrepend bool, f choykit.PacketHandler)

添加消息处理函数

func (*Node) Codec

func (s *Node) Codec() choykit.Codec

func (*Node) Context

func (s *Node) Context() *choykit.ServiceContext

func (*Node) Dispatch

func (s *Node) Dispatch(pkt *choykit.Packet) error

执行消息处理

func (*Node) Environ

func (s *Node) Environ() *choykit.Environ

func (*Node) Init

func (s *Node) Init(ctx *choykit.ServiceContext) error

func (*Node) IsClosing

func (s *Node) IsClosing() bool

func (*Node) NodeID

func (s *Node) NodeID() choykit.NodeID

func (*Node) SendPacket

func (s *Node) SendPacket(pkt *choykit.Packet) error

func (*Node) SetNodeID

func (s *Node) SetNodeID(v choykit.NodeID)

func (*Node) Shutdown

func (s *Node) Shutdown()

func (*Node) Startup

func (s *Node) Startup() error

type NodeInfoMap

type NodeInfoMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

按服务类型区分的节点信息

func NewNodeInfoMap

func NewNodeInfoMap() *NodeInfoMap

func (*NodeInfoMap) AddNode

func (m *NodeInfoMap) AddNode(info *protocol.NodeInfo)

添加一个节点

func (*NodeInfoMap) Clear

func (m *NodeInfoMap) Clear()

func (*NodeInfoMap) DeleteNode

func (m *NodeInfoMap) DeleteNode(node choykit.NodeID)

删除一个节点

func (*NodeInfoMap) DeleteService

func (m *NodeInfoMap) DeleteService(srvType uint8)

删除某一类型的所有节点

func (*NodeInfoMap) GetNodes

func (m *NodeInfoMap) GetNodes(srvType uint8) []*protocol.NodeInfo

所有本类型的节点

func (*NodeInfoMap) GetNodesBy

func (m *NodeInfoMap) GetNodesBy(srvType uint8, district uint16) []*protocol.NodeInfo

本区服所有类型的节点

type ServiceSinker

type ServiceSinker interface {
	NodeInfo() *protocol.NodeInfo
	AddDependency(*protocol.NodeInfo)
	DelDependency(bool, choykit.NodeID)
}

Jump to

Keyboard shortcuts

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