message

package
v1.1.22 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyDictionary = NewMemberDictionary()
)
View Source
var ErrIndexCodeNotFound = errors.New("dictionary: index code not found")
View Source
var ErrIndexRouteNotFound = errors.New("dictionary: index route not found")
View Source
var (
	// SerializerTypeMap is a map from route to serializer
	SerializerTypeMap = make(map[string]serializer.SerializerType)
)

Functions

func DuplicateSerializerTypeMap added in v1.1.13

func DuplicateSerializerTypeMap() map[string]serializer.SerializerType

DuplicateSerializerTypeMap returns serializers for compressed route.

func RouteSerialize

func RouteSerialize(serializerTypes map[string]serializer.SerializerType, route string, v interface{}) ([]byte, error)

func Serialize

func Serialize(v interface{}) ([]byte, error)

func ShortVersion

func ShortVersion(version string) uint32

func WriteDictionary

func WriteDictionary(items []*clusterpb.DictionaryItem)

WriteDictionary is to set dictionary when new route dictionary is found.

func WriteDictionaryItem

func WriteDictionaryItem(route string, code uint32)

WriteDictionaryItem is to set dictionary item when server registers.

func WriteSerializerItem

func WriteSerializerItem(route string, serializerType serializer.SerializerType) map[string]serializer.SerializerType

WriteSerializerItem is to set serializer item when server registers.

func WriteSerializers

func WriteSerializers(items []*clusterpb.DictionaryItem) map[string]serializer.SerializerType

WriteSerializers is to set serializers when new serializer dictionary is found.

Types

type Dictionary added in v1.0.1

type Dictionary interface {
	IndexRoute(string) (uint32, error)
	IndexCode(uint32) (string, error)
}

type LuaDictionary added in v1.0.1

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

func NewLuaDictionary added in v1.0.1

func NewLuaDictionary(file string) *LuaDictionary

func (*LuaDictionary) IndexCode added in v1.0.1

func (d *LuaDictionary) IndexCode(code uint32) (string, error)

func (*LuaDictionary) IndexRoute added in v1.0.1

func (d *LuaDictionary) IndexRoute(route string) (uint32, error)

func (*LuaDictionary) InitModule added in v1.0.1

func (d *LuaDictionary) InitModule(l *lua.LState) int

func (*LuaDictionary) LoadLua added in v1.0.1

func (d *LuaDictionary) LoadLua(file string)

type MemberDictionary added in v1.0.1

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

func DuplicateDictionary added in v1.0.1

func DuplicateDictionary() *MemberDictionary

DuplicateDictionary returns dictionary for compressed route.

func NewMemberDictionary added in v1.0.1

func NewMemberDictionary() *MemberDictionary

func (*MemberDictionary) IndexCode added in v1.0.1

func (d *MemberDictionary) IndexCode(code uint32) (string, error)

func (*MemberDictionary) IndexRoute added in v1.0.1

func (d *MemberDictionary) IndexRoute(route string) (uint32, error)

type Message

type Message struct {
	Type      Type   // message type
	Branch    uint32 // client branch
	ShortVer  uint32 // message short version
	ID        uint64 // unique id, zero while notify mode
	UnixTime  uint32 // unix time in seconds
	SessionID uint64 // server session id int64
	Route     string // route for locating service
	Data      []byte // payload
}

Message represents a unmarshaled message or a message which to be marshaled

func New

func New() *Message

New returns a new message instance

func (*Message) String

func (m *Message) String() string

String, implementation of fmt.Stringer interface

func (*Message) TypeValid added in v1.0.1

func (m *Message) TypeValid() bool

type Type

type Type byte

Type represents the type of message, which could be Request/Notify/Response/Push

const (
	Request Type = iota
	Notify
	Response
	Push
)

Message types

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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