discovery

package
v0.0.0-...-589df18 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 6 Imported by: 0

README

serverlist

本目录是常见游戏服务器列表的组织方式的一种实现。

本目录并不是 go-discovery 所必须的。

没有特殊应用情况,通常使用本目录代码,即完成对游戏服务器列表操作。

Documentation

Overview

Package discovery is a generated protocol buffer package.

It is generated from these files:

serverinfo.proto

It has these top-level messages:

ServerInfo

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(log godiscovery.ILogger)

func SetNode

func SetNode(node *Node)

Types

type IMap

type IMap interface {
	GetOne() (key, val interface{}, ok bool)

	Set(key interface{}, val interface{}) bool
	Delete(key interface{})
	Iterator() *gomap.Iterator
	Count() int
}

type IServers

type IServers interface {
	GetOne(nodeType int) (uint32, *ServerInfo, bool)
	GetAll(nodeType int) ([]*ServerInfo, bool)
	Set(nodeType int, id uint32, val *ServerInfo)
	Delete(nodeType int, id uint32)
	GetByID(id uint32) (*ServerInfo, bool)
	Count(nodeType int) int
}

func NewServersPolicyOrdered

func NewServersPolicyOrdered() IServers

func NewServersPolicyRandom

func NewServersPolicyRandom() IServers

func NewServersPolicyRoundRobin

func NewServersPolicyRoundRobin() IServers

type Node

type Node struct {
	godiscovery.Node

	Servers IServers
	// contains filtered or unexported fields
}

func GetNode

func GetNode() *Node

func NewDefaultNode

func NewDefaultNode(inst interface{}) *Node

func (*Node) GetBase

func (this *Node) GetBase() interface{}

func (*Node) GetBaseInfo

func (this *Node) GetBaseInfo() ServerInfo

func (*Node) GetPutData

func (this *Node) GetPutData() (string, error)

func (*Node) InitPolicy

func (this *Node) InitPolicy(policy Policy)

func (*Node) OnNodeJoin

func (this *Node) OnNodeJoin(nodeIP string, nodeType int, id uint32, data []byte)

func (*Node) OnNodeLeave

func (this *Node) OnNodeLeave(nodeType int, id uint32)

func (*Node) OnNodeUpdate

func (this *Node) OnNodeUpdate(nodeIP string, nodeType int, id uint32, data []byte)

func (*Node) Open

func (this *Node) Open(hosts []string, whatsmyipHost string, nodeType int, watchNodeTypes []int, putInterval int64)

func (*Node) OpenByStr

func (this *Node) OpenByStr(hostsStr string, whatsmyipHost string, nodeType int, watchNodeTypesStr string, putInterval int64)

func (*Node) SetBaseInfoIP

func (this *Node) SetBaseInfoIP(externalIp string)

func (*Node) SetBaseInfoId

func (this *Node) SetBaseInfoId(id uint32)

func (*Node) SetBaseInfoOrdered

func (this *Node) SetBaseInfoOrdered(ordered uint32)

func (*Node) SetBaseInfoType

func (this *Node) SetBaseInfoType(t uint32)

type Policy

type Policy int
const (
	Ordered    Policy // 1
	Random            // 2
	RoundRobin        // 3
)

type ServerInfo

type ServerInfo struct {
	Type       uint32 `protobuf:"varint,1,opt,name=type" json:"type,omitempty"`
	Id         uint32 `protobuf:"varint,2,opt,name=id" json:"id,omitempty"`
	ExternalIp string `protobuf:"bytes,3,opt,name=external_ip,json=externalIp" json:"external_ip,omitempty"`
	Ordered    uint32 `protobuf:"varint,4,opt,name=ordered" json:"ordered,omitempty"`
}

func (*ServerInfo) Descriptor

func (*ServerInfo) Descriptor() ([]byte, []int)

func (*ServerInfo) GetExternalIp

func (m *ServerInfo) GetExternalIp() string

func (*ServerInfo) GetId

func (m *ServerInfo) GetId() uint32

func (*ServerInfo) GetOrdered

func (m *ServerInfo) GetOrdered() uint32

func (*ServerInfo) GetType

func (m *ServerInfo) GetType() uint32

func (*ServerInfo) ProtoMessage

func (*ServerInfo) ProtoMessage()

func (*ServerInfo) Reset

func (m *ServerInfo) Reset()

func (*ServerInfo) String

func (m *ServerInfo) String() string

type Servers

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

func NewServers

func NewServers(creator func() IMap) *Servers

func (*Servers) Count

func (this *Servers) Count(nodeType int) int

func (*Servers) Delete

func (this *Servers) Delete(nodeType int, id uint32)

func (*Servers) GetAll

func (this *Servers) GetAll(nodeType int) ([]*ServerInfo, bool)

func (*Servers) GetByID

func (this *Servers) GetByID(id uint32) (m *ServerInfo, ok bool)

func (*Servers) GetOne

func (this *Servers) GetOne(nodeType int) (uint32, *ServerInfo, bool)

func (*Servers) Set

func (this *Servers) Set(nodeType int, id uint32, val *ServerInfo)

type ServersPolicyOrdered

type ServersPolicyOrdered struct {
	gomap.OrderedMap
}

ServersPolicyOrdered

func (*ServersPolicyOrdered) GetOne

func (this *ServersPolicyOrdered) GetOne() (key, val interface{}, ok bool)

type ServersPolicyRandom

type ServersPolicyRandom struct {
	gomap.RandomMap
}

ServersPolicyRandom

func (*ServersPolicyRandom) GetOne

func (this *ServersPolicyRandom) GetOne() (key, val interface{}, ok bool)

type ServersPolicyRoundRobin

type ServersPolicyRoundRobin struct {
	gomap.RoundRobinMap
}

ServersPolicyRoundRobin

func (*ServersPolicyRoundRobin) GetOne

func (this *ServersPolicyRoundRobin) GetOne() (key, val interface{}, ok bool)

Jump to

Keyboard shortcuts

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