Documentation ¶
Index ¶
- Constants
- type FreeLevel
- type InternalMsg
- type Message
- func NewMessageFromBytes(pid uint32, buf []byte, maxLength uint32) (msg *Message, err error)
- func NewMessageFromMsg(pid uint32, srcMsg *Message, maxLength uint32) (msg *Message, err error)
- func NewMessageFromReader(pid uint32, r io.ReadCloser, metaBuf []byte, maxLength uint32) (msg *Message, err error)
- func NewRawRecvMessage(pid uint32, content []byte) (msg *Message)
- func NewSendMessage(flags, sendType uint8, ttl uint8, src, dest MsgPath, content []byte) *Message
- type Meta
- type MsgPath
Constants ¶
const ( // random select one pipe to send SendTypeToOne uint8 = iota & sendTypeMask // send to all pipes SendTypeToAll // send to a destination SendTypeToDest )
send types, low 2bits
const ( // socket internal message, used by socket internal MsgFlagInternal uint8 = 1 << (iota + 2) // TODO: // MsgFlagNoSource, do not record message source MsgFlagNoSource // MsgFlagRaw is used to indicate the message is from a raw transport MsgFlagRaw // protocol control message, predefined flag, use by protocols implementations or others. MsgFlagControl )
Msg Flags
const DefaultMsgTTL = uint8(16)
DefaultMsgTTL is default msg ttl
const ( // close peer InternalMsgClosePeer uint8 = iota )
TODO: Internal Messages
const MetaSize = 8
MetaSize is the Meta data's memory byte size. TODO: update when Meta modifed
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InternalMsg ¶
type InternalMsg struct {
Type uint8
}
InternalMsg internal message content structure.
type Message ¶
type Message struct { Meta Source MsgPath Destination MsgPath // TODO: support zero copy content Content []byte // contains filtered or unexported fields }
Message is a message
func NewMessageFromBytes ¶
NewMessageFromBytes create a message from bytes
func NewMessageFromMsg ¶
NewMessageFromMsg create a message from message
func NewMessageFromReader ¶
func NewMessageFromReader(pid uint32, r io.ReadCloser, metaBuf []byte, maxLength uint32) (msg *Message, err error)
NewMessageFromReader create a message from reader
func NewRawRecvMessage ¶
NewRawRecvMessage create a new raw recv message
func NewSendMessage ¶
NewSendMessage create a message to send
func (*Message) Dup ¶
Dup create a duplicated message TODO: try effective way, like reference counting.
func (*Message) FreeByLevel ¶
FreeByLevel free message by level
type Meta ¶
type Meta struct { // Flags Flags uint8 // 6:other flags|2:send type to/one,all,dest TTL uint8 // time to live Hops uint8 // node count from origin Distance uint8 // node count to destination Length uint32 // content length }
Meta message's meta data
func (*Meta) HasAnyFlags ¶
HasAnyFlags check if meta data has any flags setted.