message

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown uint32 = iota
	JSON
	Protobuf
	RawString
)

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 (
	// Serializers is a map from route to serializer
	Serializers = make(map[string]serialize.Serializer)
)

Functions

func DuplicateSerializers added in v1.0.1

func DuplicateSerializers() map[string]serialize.Serializer

DuplicateSerializers returns serializers for compressed route.

func GetSerializer

func GetSerializer(typ uint32) serialize.Serializer

func GetSerializerType

func GetSerializerType(s serialize.Serializer) uint32

func RouteSerialize

func RouteSerialize(serializers map[string]serialize.Serializer, 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, typ uint32) map[string]serialize.Serializer

WriteSerializerItem is to set serializer item when server registers.

func WriteSerializers

func WriteSerializers(items []*clusterpb.DictionaryItem) map[string]serialize.Serializer

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
	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