Documentation ¶
Overview ¶
Package message provides a common messaging header for IPC and Network communication. The body of the message can be used to hold raw data or can hold a marshalled protobuf.
Package message is a generated protocol buffer package.
It is generated from these files:
message/message.proto
It has these top-level messages:
Header Addrpb
Index ¶
- Constants
- type Addrpb
- func (*Addrpb) Descriptor() ([]byte, []int)
- func (a *Addrpb) GetAddr() *rnet.Addr
- func (m *Addrpb) GetIp() []byte
- func (m *Addrpb) GetPort() uint32
- func (m *Addrpb) GetZone() string
- func (a *Addrpb) Marshal() []byte
- func (*Addrpb) ProtoMessage()
- func (m *Addrpb) Reset()
- func (m *Addrpb) String() string
- type BitFlag
- type Header
- func (h *Header) BodyString() string
- func (h *Header) BodyToUint32() uint32
- func (h *Header) CheckFlag(flag BitFlag) bool
- func (*Header) Descriptor() ([]byte, []int)
- func (h *Header) GetAddr() *rnet.Addr
- func (m *Header) GetAddrpb() *Addrpb
- func (m *Header) GetBody() []byte
- func (m *Header) GetFlags() uint32
- func (m *Header) GetId() uint32
- func (m *Header) GetNodeID() []byte
- func (m *Header) GetService() uint32
- func (h *Header) GetType() Type
- func (m *Header) GetType32() uint32
- func (h *Header) IsFromNet() bool
- func (h *Header) IsQuery() bool
- func (h *Header) IsResponse() bool
- func (h *Header) IsToNet() bool
- func (h *Header) Marshal() []byte
- func (*Header) ProtoMessage()
- func (m *Header) Reset()
- func (h *Header) SetAddr(addr *rnet.Addr) *Header
- func (h *Header) SetBody(body interface{}) *Header
- func (h *Header) SetFlag(flag BitFlag)
- func (h *Header) SetType(t Type)
- func (m *Header) String() string
- func (h *Header) Unmarshal(pb proto.Message) error
- func (h *Header) UnsetFlag(flag BitFlag)
- type Type
Constants ¶
const ( QueryFlag = BitFlag(1 << (iota)) ResponseFlag FromNet ToNet )
Flag masks Flags field
const ( Undefined = Type(iota) GetPort GetIP RegisterService Test Ping NetSend NetReceive AddBeacon GetPubKey Die SessionData StaticKey RandomKey )
Types for messages
const ( BeaconService uint32 = 19860714 PoolService uint32 = 1111111111 )
Services
const ServiceTypeOffset = 1024
ServiceTypeOffset claims the first 1024 values are reserved, after that, values are specific to the service handling them.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Addrpb ¶
type Addrpb struct { Ip []byte `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"` Port uint32 `protobuf:"varint,2,opt,name=port" json:"port,omitempty"` Zone string `protobuf:"bytes,3,opt,name=zone" json:"zone,omitempty"` }
func UnmarshalAddrpb ¶
UnmarshalAddrpb unmarshals a buffer to an Addrpb. If there is an error it is logged and a nil value is returned.
func (*Addrpb) Descriptor ¶
func (*Addrpb) Marshal ¶
Marshal a header to a buffer. If there is an error it is logged and nil is returned.
func (*Addrpb) ProtoMessage ¶
func (*Addrpb) ProtoMessage()
type Header ¶
type Header struct { Type32 uint32 `protobuf:"varint,1,opt,name=type32" json:"type32,omitempty"` Service uint32 `protobuf:"varint,2,opt,name=service" json:"service,omitempty"` Flags uint32 `protobuf:"varint,3,opt,name=flags" json:"flags,omitempty"` Body []byte `protobuf:"bytes,4,opt,name=body,proto3" json:"body,omitempty"` Id uint32 `protobuf:"varint,5,opt,name=id" json:"id,omitempty"` NodeID []byte `protobuf:"bytes,6,opt,name=nodeID,proto3" json:"nodeID,omitempty"` Addrpb *Addrpb `protobuf:"bytes,7,opt,name=Addrpb" json:"Addrpb,omitempty"` }
func Unmarshal ¶
Unmarshal a buffer to a header. If there is an error it is logged and a nil value is returned.
func (*Header) BodyString ¶
BodyString returns the body as a string
func (*Header) BodyToUint32 ¶
BodyToUint32 uses dist.ribut.us/serial to Unmarshal the body.
func (*Header) Descriptor ¶
func (*Header) GetService ¶
func (*Header) IsResponse ¶
IsResponse checks if the underlying type is a query
func (*Header) Marshal ¶
Marshal a header to a buffer. If there is an error it is logged and nil is returned.
func (*Header) ProtoMessage ¶
func (*Header) ProtoMessage()
func (*Header) SetBody ¶
SetBody takes various types and tries to set the Body field. If body is nil, that will set the body to nil. If body is a []byte, that will be set on the body. If it is a string, it will be cast to []byte. If the body is a proto.Message it will be marshalled and the serialized data will be used. If it is a uint32, dist.ribut.us/serial will be used to marshal the value into body.