cluster

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 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 DependencyServiceTypes added in v1.0.5

func DependencyServiceTypes(serviceDependency string) ([]uint8, error)

func SignAccessToken

func SignAccessToken(node fatchoy.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 fatchoy.NodeID)

func (*Backend) Init

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

func (*Backend) IsMyDependency

func (s *Backend) IsMyDependency(node fatchoy.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
}

基于ETCD的服务发现

func NewEtcdDiscovery

func NewEtcdDiscovery(env *fatchoy.Environ, sink ServiceSinker) *EtcdDiscovery

func (*EtcdDiscovery) Close

func (d *EtcdDiscovery) Close()

func (*EtcdDiscovery) Start

func (d *EtcdDiscovery) Start() error

type Node

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

节点

func (*Node) AddMessageHandler

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

添加消息处理函数

func (*Node) Context

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

func (*Node) Dispatch

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

执行消息处理

func (*Node) Environ

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

func (*Node) Init

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

func (*Node) IsClosing

func (s *Node) IsClosing() bool

func (*Node) NodeID

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

func (*Node) SendPacket

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

func (*Node) SetNodeID

func (s *Node) SetNodeID(v fatchoy.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 fatchoy.NodeID)

删除一个节点

func (*NodeInfoMap) DeleteService

func (m *NodeInfoMap) DeleteService(srvType uint8)

删除某一类型的所有节点

func (*NodeInfoMap) GetNodes

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

所有本类型的节点

type ServiceSinker

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

Jump to

Keyboard shortcuts

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