pb

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

Message

消息数据,protobuf格式,用于think中传导

Type

消息类型,每个消息名须以G || P || S开头,对应不同的处理,这个主要是k8s中需要区分不同的消息

  • TypeUndefined: 未定义类型,将无法处理
  • TypeGET: GET类型,消息名以G开头,发送请求,获得返回,一次
  • TypePOST: POST类型,消息名以P开头,发送消息,无需返回
  • TypeSTREAM: STREAM类型,消息名以S开头,建立管道,消息自由收发

API

AnyDecode

将[]byte 消息编码为Any 消息

AnyEncode

将Any 消息编码为[]byte 消息

AnyMessageNameTrimed

获取处理过的any.Any 消息名,去掉可能包含的报名

GetServerType

获取服务类型,用于使用不同的方式处理消息

Documentation

Index

Constants

View Source
const (
	TypeUndefined = iota //NOTE: 未定义的类型,表明出错了
	TypeGET              //NOTE: get消息,需要一个返回
	TypePOST             //NOTE: post消息
	TypeSTREAM           //NOTE: 流消息
	TypeMQ               //NOTE: 消息队列
)

Message Type 用于甄别message 需要用那种方式调用

Variables

This section is empty.

Functions

func AnyDecode

func AnyDecode(msg []byte) (a *any.Any, err error)

AnyDecode used to unmarshal net data to expect data

func AnyEncode

func AnyEncode(anyMsg *any.Any) (buf []byte, err error)

AnyEncode used to marshal data to net data

func AnyMessageNameTrimed added in v0.0.3

func AnyMessageNameTrimed(anyMsg *any.Any) (messageName string, err error)

AnyMessageNameTrimed 处理后的any.Any 消息名,去掉可能包含的包名

func GetServerType

func GetServerType(anyMsg *any.Any) (t int, err error)

GetServerType 获得服务类型

Types

type Message

type Message struct {
	Token                string   `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
	Data                 *any.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	AimTokens            []string `protobuf:"bytes,3,rep,name=aimTokens,proto3" json:"aimTokens,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Message 用于服务间传输的消息,为了绑定Token,所以不直接传输data。服务名可直接通过data 获取,所以不再使用Key字段

func (*Message) Descriptor

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

func (*Message) GetAimTokens

func (m *Message) GetAimTokens() []string

func (*Message) GetData

func (m *Message) GetData() *any.Any

func (*Message) GetToken

func (m *Message) GetToken() string

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) String

func (m *Message) String() string

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

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

func (*Message) XXX_Merge

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

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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