core

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeUrl

func DecodeUrl(url string) (host string, port uint, path string)

func EncodeUrl

func EncodeUrl(host string, port uint, path string) string

Types

type Cluster

type Cluster interface {
	ID() string
	// 开始主动请求连接其他节点
	Start()
	// 被动接收到协议请求信息
	Receive(c Connection, t message.Topic, data string)
	Stable() bool
	Master() Master
	Add(host string, port uint, path string, level int) Master
	AddUrl(url string, level int) Master
	Del(url string)
	Range(func(m Master) bool)
	RangeConn(func(c Connection) bool)
	Slave() []Connection
}

type ConnCfg

type ConnCfg interface {
	Validate()
	MsgSerializer() *message.Serializer
	Ctx() context.Context
	Webds() Webds
	PingPeriod() time.Duration
	ReadTimeout() time.Duration
	ReadBufferSize() int64
	BinaryMessages() bool
}

type ConnectFunc

type ConnectFunc = message.FuncBlank

type Connection

type Connection interface {
	ID() string
	// 判断是个被动建立的连接还是主动建立的连接
	Passive() bool
	TargetID() string
	Level() int
	SetLevel(int)
	TargetUrl() string
	SetTargetID(string)
	SetTargetHost(string)
	SetTargetPort(uint)
	SetTargetPath(string)

	// 该方法仅主动方有效
	OnConnect(ConnectFunc) message.Subscriber
	OnDisconnect(DisconnectFunc) message.Subscriber
	OnError(ErrorFunc) message.Subscriber
	FireOnError(err error)
	// 发送给对方节点广播消息
	Publisher(string) func(interface{})
	// 发送给对方节点非广播消息
	Echo(topic message.Topic, data interface{})
	// 通知对方自己订阅消息,并注册响应函数
	Subscribe(message.Topic, message.Func) message.Subscriber
	Wait() error
	io.WriteCloser
	Type() int
	Alive() bool
}

type DisconnectFunc

type DisconnectFunc = message.FuncBlank

type ErrorFunc

type ErrorFunc = message.FuncError

type Master

type Master interface {
	String() string
	Url() string
	ID() string
	Level() int
	Alive() bool
	Conn() Connection
}

type Webds

type Webds interface {
	AddConnection(Connection) bool
	DelConnection(id string)
	GetConnection(id string) Connection
	Range(func(id string, c Connection) bool)
	Broadcast(topic string, msg []byte, id string)
	Subscribe(topic string, id string)
	CancelSubscribe(topic string, id string)
	CancelAll(id string)
	Topics() trie.Trie
	Cluster() Cluster
	ID() string
}

Jump to

Keyboard shortcuts

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