node

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultPassword = "password"

	DefaultNodePingInterval = 10

	NodeAddress = "node_address"
)
View Source
const (
	AuthNodeMsgType           int32 = 1
	ClientMsgType             int32 = 2
	PingMsgType               int32 = 3
	AuthBusinessClientMsgType int32 = 4
	BindNodeIdMsgType         int32 = 5
)

Variables

View Source
var PingMsg []byte

Functions

func GetUUID

func GetUUID() string

GetUUID return a uuid

Types

type AuthMsg

type AuthMsg struct {
	NodeId               string   `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
	Password             string   `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*AuthMsg) Descriptor

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

func (*AuthMsg) GetNodeId

func (m *AuthMsg) GetNodeId() string

func (*AuthMsg) GetPassword

func (m *AuthMsg) GetPassword() string

func (*AuthMsg) ProtoMessage

func (*AuthMsg) ProtoMessage()

func (*AuthMsg) Reset

func (m *AuthMsg) Reset()

func (*AuthMsg) String

func (m *AuthMsg) String() string

func (*AuthMsg) XXX_DiscardUnknown

func (m *AuthMsg) XXX_DiscardUnknown()

func (*AuthMsg) XXX_Marshal

func (m *AuthMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*AuthMsg) XXX_Merge

func (m *AuthMsg) XXX_Merge(src proto.Message)

func (*AuthMsg) XXX_Size

func (m *AuthMsg) XXX_Size() int

func (*AuthMsg) XXX_Unmarshal

func (m *AuthMsg) XXX_Unmarshal(b []byte) error

type BatchData

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

type BindNodeIdMsg

type BindNodeIdMsg struct {
	NodeId               string   `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*BindNodeIdMsg) Descriptor

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

func (*BindNodeIdMsg) GetNodeId

func (m *BindNodeIdMsg) GetNodeId() string

func (*BindNodeIdMsg) ProtoMessage

func (*BindNodeIdMsg) ProtoMessage()

func (*BindNodeIdMsg) Reset

func (m *BindNodeIdMsg) Reset()

func (*BindNodeIdMsg) String

func (m *BindNodeIdMsg) String() string

func (*BindNodeIdMsg) XXX_DiscardUnknown

func (m *BindNodeIdMsg) XXX_DiscardUnknown()

func (*BindNodeIdMsg) XXX_Marshal

func (m *BindNodeIdMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*BindNodeIdMsg) XXX_Merge

func (m *BindNodeIdMsg) XXX_Merge(src proto.Message)

func (*BindNodeIdMsg) XXX_Size

func (m *BindNodeIdMsg) XXX_Size() int

func (*BindNodeIdMsg) XXX_Unmarshal

func (m *BindNodeIdMsg) XXX_Unmarshal(b []byte) error

type ClientsMsg

type ClientsMsg struct {
	ReceiveClientIds     []string `protobuf:"bytes,1,rep,name=receive_client_ids,json=receiveClientIds,proto3" json:"receive_client_ids,omitempty"`
	Data                 []byte   `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*ClientsMsg) Descriptor

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

func (*ClientsMsg) GetData

func (m *ClientsMsg) GetData() []byte

func (*ClientsMsg) GetReceiveClientIds

func (m *ClientsMsg) GetReceiveClientIds() []string

func (*ClientsMsg) ProtoMessage

func (*ClientsMsg) ProtoMessage()

func (*ClientsMsg) Reset

func (m *ClientsMsg) Reset()

func (*ClientsMsg) String

func (m *ClientsMsg) String() string

func (*ClientsMsg) XXX_DiscardUnknown

func (m *ClientsMsg) XXX_DiscardUnknown()

func (*ClientsMsg) XXX_Marshal

func (m *ClientsMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ClientsMsg) XXX_Merge

func (m *ClientsMsg) XXX_Merge(src proto.Message)

func (*ClientsMsg) XXX_Size

func (m *ClientsMsg) XXX_Size() int

func (*ClientsMsg) XXX_Unmarshal

func (m *ClientsMsg) XXX_Unmarshal(b []byte) error

type Context

type Context struct {
	Conn     protocol.Connection
	ClientId string
	Msg      []byte
}

Params of onMsg

type DefaultPlugin

type DefaultPlugin struct {
}

func (*DefaultPlugin) OnClose

func (this *DefaultPlugin) OnClose(conn protocol.Connection)

func (*DefaultPlugin) OnConnect

func (this *DefaultPlugin) OnConnect(conn protocol.Connection)

type Msg

type Msg struct {
	MsgType              int32    `protobuf:"varint,1,opt,name=msg_type,json=msgType,proto3" json:"msg_type,omitempty"`
	Data                 []byte   `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Msg) Descriptor

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

func (*Msg) GetData

func (m *Msg) GetData() []byte

func (*Msg) GetMsgType

func (m *Msg) GetMsgType() int32

func (*Msg) ProtoMessage

func (*Msg) ProtoMessage()

func (*Msg) Reset

func (m *Msg) Reset()

func (*Msg) String

func (m *Msg) String() string

func (*Msg) XXX_DiscardUnknown

func (m *Msg) XXX_DiscardUnknown()

func (*Msg) XXX_Marshal

func (m *Msg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Msg) XXX_Merge

func (m *Msg) XXX_Merge(src proto.Message)

func (*Msg) XXX_Size

func (m *Msg) XXX_Size() int

func (*Msg) XXX_Unmarshal

func (m *Msg) XXX_Unmarshal(b []byte) error

type Node

type Node interface {
	// SetClientIdOnline binds the client ID to the connection
	SetClientIdOnline(conn protocol.Connection, clientId string) error
	// OnClientPing updates the client heartbeat status
	OnClientPing(clientId string) error
	// IsOnline gets the online status of the clientId
	IsOnline(clientId string) bool
	// SendToClientId sends a message to a clientId
	SendToClientId(clientId string, req []byte) error
	//  SendToClientId sends a message to multiple clientIds
	SendToClientIds(clientIds []string, req []byte) error
}

func NewNode

func NewNode(cfg *NodeConf) (Node, error)

NewNode return a Node

type NodeConf

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

NodeConf node config

func NewNodeConf

func NewNodeConf(addr string, protocolHandler protocol.Protocol, sessionStorageHandler session_storage.SessionStorage, discoveryHandler discovery.ServiceDiscovery, onMsg func(context *Context)) *NodeConf

NewNodeConf creates a new NodeConf.

func (*NodeConf) WithAddr added in v1.0.1

func (conf *NodeConf) WithAddr(addr string) *NodeConf

WithAddr sets the addr for node cluster

func (*NodeConf) WithClientInterval

func (conf *NodeConf) WithClientInterval(pingInterval int64) *NodeConf

WithClientInterval sets the heartbeat interval

func (*NodeConf) WithInternalPort

func (conf *NodeConf) WithInternalPort(port int64) *NodeConf

WithInternalPort sets the port for internal protocol

func (*NodeConf) WithPassword

func (conf *NodeConf) WithPassword(password string) *NodeConf

WithPassword sets the password for transport node

func (*NodeConf) WithPlugin

func (conf *NodeConf) WithPlugin(plugin Plugin) *NodeConf

WithPlugin sets the plugin

func (*NodeConf) WithPort

func (conf *NodeConf) WithPort(port int64) *NodeConf

WithPort sets the port

type NodeInfo

type NodeInfo struct {
	ClientAddress        string   `protobuf:"bytes,1,opt,name=client_address,json=clientAddress,proto3" json:"client_address,omitempty"`
	ClientCount          int64    `protobuf:"varint,2,opt,name=client_count,json=clientCount,proto3" json:"client_count,omitempty"`
	Timestamp            int64    `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*NodeInfo) Descriptor

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

func (*NodeInfo) GetClientAddress

func (m *NodeInfo) GetClientAddress() string

func (*NodeInfo) GetClientCount

func (m *NodeInfo) GetClientCount() int64

func (*NodeInfo) GetTimestamp

func (m *NodeInfo) GetTimestamp() int64

func (*NodeInfo) ProtoMessage

func (*NodeInfo) ProtoMessage()

func (*NodeInfo) Reset

func (m *NodeInfo) Reset()

func (*NodeInfo) String

func (m *NodeInfo) String() string

func (*NodeInfo) XXX_DiscardUnknown

func (m *NodeInfo) XXX_DiscardUnknown()

func (*NodeInfo) XXX_Marshal

func (m *NodeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*NodeInfo) XXX_Merge

func (m *NodeInfo) XXX_Merge(src proto.Message)

func (*NodeInfo) XXX_Size

func (m *NodeInfo) XXX_Size() int

func (*NodeInfo) XXX_Unmarshal

func (m *NodeInfo) XXX_Unmarshal(b []byte) error

type Plugin

type Plugin interface {
	OnConnect(conn protocol.Connection)
	OnClose(conn protocol.Connection)
}

type RedisNode

type RedisNode struct {
	RedisConf *redis.Options
	Position  uint32 // The position of hash
}

RedisNode the hash redis node config

type Session

type Session struct {
	Conn     protocol.Connection
	ClientId string
}

func (*Session) CasClientId

func (s *Session) CasClientId(newClientId string) string

CasClientId sets the session uid and return oldClientId

func (*Session) LoadClientId

func (s *Session) LoadClientId() string

LoadClientId returns the session uid.

func (*Session) StoreClientId

func (s *Session) StoreClientId(newClientId string)

StoreClientId sets the session uid.

Jump to

Keyboard shortcuts

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