grpc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxBodySize max proto body size
	MaxBodySize = int32(1 << 14)
)

Variables

View Source
var (
	Op_name = map[int32]string{
		0:  "Undefined",
		1:  "Auth",
		2:  "AuthReply",
		3:  "Heartbeat",
		4:  "HeartbeatReply",
		5:  "Disconnect",
		6:  "DisconnectReply",
		7:  "SendMsg",
		8:  "SendMsgReply",
		9:  "ReceiveMsg",
		10: "ReceiveMsgReply",
		11: "ProtoReady",
		12: "ProtoFinish",
		13: "Raw",
		14: "SyncMsgReq",
		15: "SyncMsgReply",
		16: "RePush",
	}
	Op_value = map[string]int32{
		"Undefined":       0,
		"Auth":            1,
		"AuthReply":       2,
		"Heartbeat":       3,
		"HeartbeatReply":  4,
		"Disconnect":      5,
		"DisconnectReply": 6,
		"SendMsg":         7,
		"SendMsgReply":    8,
		"ReceiveMsg":      9,
		"ReceiveMsgReply": 10,
		"ProtoReady":      11,
		"ProtoFinish":     12,
		"Raw":             13,
		"SyncMsgReq":      14,
		"SyncMsgReply":    15,
		"RePush":          16,
	}
)

Enum value maps for Op.

View Source
var (
	// ErrProtoPackLen proto packet len error
	ErrProtoPackLen = errors.New("default server codec pack length error")
	// ErrProtoHeaderLen proto header len error
	ErrProtoHeaderLen = errors.New("default server codec header length error")
)
View Source
var (
	// ProtoReady proto ready
	ProtoReady = &Proto{Op: int32(Op_ProtoReady)}
	// ProtoFinish proto finish
	ProtoFinish = &Proto{Op: int32(Op_ProtoFinish)}
)
View Source
var Comet_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "im.comet.Comet",
	HandlerType: (*CometServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "PushMsg",
			Handler:    _Comet_PushMsg_Handler,
		},
		{
			MethodName: "Broadcast",
			Handler:    _Comet_Broadcast_Handler,
		},
		{
			MethodName: "BroadcastGroup",
			Handler:    _Comet_BroadcastGroup_Handler,
		},
		{
			MethodName: "JoinGroups",
			Handler:    _Comet_JoinGroups_Handler,
		},
		{
			MethodName: "LeaveGroups",
			Handler:    _Comet_LeaveGroups_Handler,
		},
		{
			MethodName: "DelGroups",
			Handler:    _Comet_DelGroups_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "comet.proto",
}

Comet_ServiceDesc is the grpc.ServiceDesc for Comet service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_comet_proto protoreflect.FileDescriptor

Functions

func RegisterCometServer

func RegisterCometServer(s grpc.ServiceRegistrar, srv CometServer)

Types

type AuthMsg

type AuthMsg struct {
	AppId string `protobuf:"bytes,1,opt,name=appId,proto3" json:"appId,omitempty"`
	Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
	Ext   []byte `protobuf:"bytes,3,opt,name=ext,proto3" json:"ext,omitempty"` // 其它业务方可能需要的信息
	// contains filtered or unexported fields
}

Proto 中 Op 为 OpAuth 时, body 必须可以反序列化为 AuthMsg

func (*AuthMsg) Descriptor deprecated

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

Deprecated: Use AuthMsg.ProtoReflect.Descriptor instead.

func (*AuthMsg) GetAppId

func (x *AuthMsg) GetAppId() string

func (*AuthMsg) GetExt

func (x *AuthMsg) GetExt() []byte

func (*AuthMsg) GetToken

func (x *AuthMsg) GetToken() string

func (*AuthMsg) ProtoMessage

func (*AuthMsg) ProtoMessage()

func (*AuthMsg) ProtoReflect

func (x *AuthMsg) ProtoReflect() protoreflect.Message

func (*AuthMsg) Reset

func (x *AuthMsg) Reset()

func (*AuthMsg) String

func (x *AuthMsg) String() string

type BroadcastGroupReply

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

func (*BroadcastGroupReply) Descriptor deprecated

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

Deprecated: Use BroadcastGroupReply.ProtoReflect.Descriptor instead.

func (*BroadcastGroupReply) ProtoMessage

func (*BroadcastGroupReply) ProtoMessage()

func (*BroadcastGroupReply) ProtoReflect

func (x *BroadcastGroupReply) ProtoReflect() protoreflect.Message

func (*BroadcastGroupReply) Reset

func (x *BroadcastGroupReply) Reset()

func (*BroadcastGroupReply) String

func (x *BroadcastGroupReply) String() string

type BroadcastGroupReq

type BroadcastGroupReq struct {
	GroupID string `protobuf:"bytes,1,opt,name=groupID,proto3" json:"groupID,omitempty"`
	Proto   *Proto `protobuf:"bytes,2,opt,name=proto,proto3" json:"proto,omitempty"`
	// contains filtered or unexported fields
}

func (*BroadcastGroupReq) Descriptor deprecated

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

Deprecated: Use BroadcastGroupReq.ProtoReflect.Descriptor instead.

func (*BroadcastGroupReq) GetGroupID

func (x *BroadcastGroupReq) GetGroupID() string

func (*BroadcastGroupReq) GetProto

func (x *BroadcastGroupReq) GetProto() *Proto

func (*BroadcastGroupReq) ProtoMessage

func (*BroadcastGroupReq) ProtoMessage()

func (*BroadcastGroupReq) ProtoReflect

func (x *BroadcastGroupReq) ProtoReflect() protoreflect.Message

func (*BroadcastGroupReq) Reset

func (x *BroadcastGroupReq) Reset()

func (*BroadcastGroupReq) String

func (x *BroadcastGroupReq) String() string

type BroadcastReply

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

func (*BroadcastReply) Descriptor deprecated

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

Deprecated: Use BroadcastReply.ProtoReflect.Descriptor instead.

func (*BroadcastReply) ProtoMessage

func (*BroadcastReply) ProtoMessage()

func (*BroadcastReply) ProtoReflect

func (x *BroadcastReply) ProtoReflect() protoreflect.Message

func (*BroadcastReply) Reset

func (x *BroadcastReply) Reset()

func (*BroadcastReply) String

func (x *BroadcastReply) String() string

type BroadcastReq

type BroadcastReq struct {
	ProtoOp int32  `protobuf:"varint,1,opt,name=protoOp,proto3" json:"protoOp,omitempty"`
	Proto   *Proto `protobuf:"bytes,2,opt,name=proto,proto3" json:"proto,omitempty"`
	// contains filtered or unexported fields
}

func (*BroadcastReq) Descriptor deprecated

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

Deprecated: Use BroadcastReq.ProtoReflect.Descriptor instead.

func (*BroadcastReq) GetProto

func (x *BroadcastReq) GetProto() *Proto

func (*BroadcastReq) GetProtoOp

func (x *BroadcastReq) GetProtoOp() int32

func (*BroadcastReq) ProtoMessage

func (*BroadcastReq) ProtoMessage()

func (*BroadcastReq) ProtoReflect

func (x *BroadcastReq) ProtoReflect() protoreflect.Message

func (*BroadcastReq) Reset

func (x *BroadcastReq) Reset()

func (*BroadcastReq) String

func (x *BroadcastReq) String() string

type CometClient

type CometClient interface {
	PushMsg(ctx context.Context, in *PushMsgReq, opts ...grpc.CallOption) (*PushMsgReply, error)
	Broadcast(ctx context.Context, in *BroadcastReq, opts ...grpc.CallOption) (*BroadcastReply, error)
	BroadcastGroup(ctx context.Context, in *BroadcastGroupReq, opts ...grpc.CallOption) (*BroadcastGroupReply, error)
	JoinGroups(ctx context.Context, in *JoinGroupsReq, opts ...grpc.CallOption) (*JoinGroupsReply, error)
	LeaveGroups(ctx context.Context, in *LeaveGroupsReq, opts ...grpc.CallOption) (*LeaveGroupsReply, error)
	DelGroups(ctx context.Context, in *DelGroupsReq, opts ...grpc.CallOption) (*DelGroupsReply, error)
}

CometClient is the client API for Comet service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewCometClient

func NewCometClient(cc grpc.ClientConnInterface) CometClient

type CometServer

type CometServer interface {
	PushMsg(context.Context, *PushMsgReq) (*PushMsgReply, error)
	Broadcast(context.Context, *BroadcastReq) (*BroadcastReply, error)
	BroadcastGroup(context.Context, *BroadcastGroupReq) (*BroadcastGroupReply, error)
	JoinGroups(context.Context, *JoinGroupsReq) (*JoinGroupsReply, error)
	LeaveGroups(context.Context, *LeaveGroupsReq) (*LeaveGroupsReply, error)
	DelGroups(context.Context, *DelGroupsReq) (*DelGroupsReply, error)
	// contains filtered or unexported methods
}

CometServer is the server API for Comet service. All implementations must embed UnimplementedCometServer for forward compatibility

type DelGroupsReply

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

func (*DelGroupsReply) Descriptor deprecated

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

Deprecated: Use DelGroupsReply.ProtoReflect.Descriptor instead.

func (*DelGroupsReply) ProtoMessage

func (*DelGroupsReply) ProtoMessage()

func (*DelGroupsReply) ProtoReflect

func (x *DelGroupsReply) ProtoReflect() protoreflect.Message

func (*DelGroupsReply) Reset

func (x *DelGroupsReply) Reset()

func (*DelGroupsReply) String

func (x *DelGroupsReply) String() string

type DelGroupsReq

type DelGroupsReq struct {
	Gid []string `protobuf:"bytes,1,rep,name=gid,proto3" json:"gid,omitempty"`
	// contains filtered or unexported fields
}

func (*DelGroupsReq) Descriptor deprecated

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

Deprecated: Use DelGroupsReq.ProtoReflect.Descriptor instead.

func (*DelGroupsReq) GetGid

func (x *DelGroupsReq) GetGid() []string

func (*DelGroupsReq) ProtoMessage

func (*DelGroupsReq) ProtoMessage()

func (*DelGroupsReq) ProtoReflect

func (x *DelGroupsReq) ProtoReflect() protoreflect.Message

func (*DelGroupsReq) Reset

func (x *DelGroupsReq) Reset()

func (*DelGroupsReq) String

func (x *DelGroupsReq) String() string

type Empty

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

func (*Empty) Descriptor deprecated

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

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

func (x *Empty) ProtoReflect() protoreflect.Message

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

type JoinGroupsReply

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

func (*JoinGroupsReply) Descriptor deprecated

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

Deprecated: Use JoinGroupsReply.ProtoReflect.Descriptor instead.

func (*JoinGroupsReply) ProtoMessage

func (*JoinGroupsReply) ProtoMessage()

func (*JoinGroupsReply) ProtoReflect

func (x *JoinGroupsReply) ProtoReflect() protoreflect.Message

func (*JoinGroupsReply) Reset

func (x *JoinGroupsReply) Reset()

func (*JoinGroupsReply) String

func (x *JoinGroupsReply) String() string

type JoinGroupsReq

type JoinGroupsReq struct {
	Keys []string `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"`
	Gid  []string `protobuf:"bytes,2,rep,name=gid,proto3" json:"gid,omitempty"`
	// contains filtered or unexported fields
}

func (*JoinGroupsReq) Descriptor deprecated

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

Deprecated: Use JoinGroupsReq.ProtoReflect.Descriptor instead.

func (*JoinGroupsReq) GetGid

func (x *JoinGroupsReq) GetGid() []string

func (*JoinGroupsReq) GetKeys

func (x *JoinGroupsReq) GetKeys() []string

func (*JoinGroupsReq) ProtoMessage

func (*JoinGroupsReq) ProtoMessage()

func (*JoinGroupsReq) ProtoReflect

func (x *JoinGroupsReq) ProtoReflect() protoreflect.Message

func (*JoinGroupsReq) Reset

func (x *JoinGroupsReq) Reset()

func (*JoinGroupsReq) String

func (x *JoinGroupsReq) String() string

type LeaveGroupsReply

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

func (*LeaveGroupsReply) Descriptor deprecated

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

Deprecated: Use LeaveGroupsReply.ProtoReflect.Descriptor instead.

func (*LeaveGroupsReply) ProtoMessage

func (*LeaveGroupsReply) ProtoMessage()

func (*LeaveGroupsReply) ProtoReflect

func (x *LeaveGroupsReply) ProtoReflect() protoreflect.Message

func (*LeaveGroupsReply) Reset

func (x *LeaveGroupsReply) Reset()

func (*LeaveGroupsReply) String

func (x *LeaveGroupsReply) String() string

type LeaveGroupsReq

type LeaveGroupsReq struct {
	Keys []string `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"`
	Gid  []string `protobuf:"bytes,2,rep,name=gid,proto3" json:"gid,omitempty"`
	// contains filtered or unexported fields
}

func (*LeaveGroupsReq) Descriptor deprecated

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

Deprecated: Use LeaveGroupsReq.ProtoReflect.Descriptor instead.

func (*LeaveGroupsReq) GetGid

func (x *LeaveGroupsReq) GetGid() []string

func (*LeaveGroupsReq) GetKeys

func (x *LeaveGroupsReq) GetKeys() []string

func (*LeaveGroupsReq) ProtoMessage

func (*LeaveGroupsReq) ProtoMessage()

func (*LeaveGroupsReq) ProtoReflect

func (x *LeaveGroupsReq) ProtoReflect() protoreflect.Message

func (*LeaveGroupsReq) Reset

func (x *LeaveGroupsReq) Reset()

func (*LeaveGroupsReq) String

func (x *LeaveGroupsReq) String() string

type Op

type Op int32
const (
	Op_Undefined       Op = 0
	Op_Auth            Op = 1
	Op_AuthReply       Op = 2
	Op_Heartbeat       Op = 3
	Op_HeartbeatReply  Op = 4
	Op_Disconnect      Op = 5
	Op_DisconnectReply Op = 6
	Op_SendMsg         Op = 7
	Op_SendMsgReply    Op = 8 //客户端回复消息已收到
	Op_ReceiveMsg      Op = 9
	Op_ReceiveMsgReply Op = 10
	Op_ProtoReady      Op = 11
	Op_ProtoFinish     Op = 12
	Op_Raw             Op = 13
	Op_SyncMsgReq      Op = 14
	Op_SyncMsgReply    Op = 15
	Op_RePush          Op = 16
)

func (Op) Descriptor

func (Op) Descriptor() protoreflect.EnumDescriptor

func (Op) Enum

func (x Op) Enum() *Op

func (Op) EnumDescriptor deprecated

func (Op) EnumDescriptor() ([]byte, []int)

Deprecated: Use Op.Descriptor instead.

func (Op) Number

func (x Op) Number() protoreflect.EnumNumber

func (Op) String

func (x Op) String() string

func (Op) Type

func (Op) Type() protoreflect.EnumType

type Proto

type Proto struct {
	Ver  int32  `protobuf:"varint,1,opt,name=ver,proto3" json:"ver,omitempty"`
	Op   int32  `protobuf:"varint,2,opt,name=op,proto3" json:"op,omitempty"`
	Seq  int32  `protobuf:"varint,3,opt,name=seq,proto3" json:"seq,omitempty"`
	Ack  int32  `protobuf:"varint,4,opt,name=ack,proto3" json:"ack,omitempty"`
	Body []byte `protobuf:"bytes,5,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

func (*Proto) Descriptor deprecated

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

Deprecated: Use Proto.ProtoReflect.Descriptor instead.

func (*Proto) GetAck

func (x *Proto) GetAck() int32

func (*Proto) GetBody

func (x *Proto) GetBody() []byte

func (*Proto) GetOp

func (x *Proto) GetOp() int32

func (*Proto) GetSeq

func (x *Proto) GetSeq() int32

func (*Proto) GetVer

func (x *Proto) GetVer() int32

func (*Proto) ProtoMessage

func (*Proto) ProtoMessage()

func (*Proto) ProtoReflect

func (x *Proto) ProtoReflect() protoreflect.Message

func (*Proto) ReadTCP

func (p *Proto) ReadTCP(rr *bufio.Reader) (err error)

ReadTCP read a proto from TCP reader.

func (*Proto) ReadWebsocket

func (p *Proto) ReadWebsocket(ws *websocket.Conn) (err error)

ReadWebsocket read a proto from websocket connection.

func (*Proto) ReadWebsocket2

func (p *Proto) ReadWebsocket2(ws *gws.Conn) (err error)

ReadWebsocket read a proto from websocket connection.

func (*Proto) Reset

func (x *Proto) Reset()

func (*Proto) String

func (x *Proto) String() string

func (*Proto) WriteTCP

func (p *Proto) WriteTCP(wr *bufio.Writer) (err error)

WriteTCP write a proto to TCP writer.

func (*Proto) WriteTCPHeart

func (p *Proto) WriteTCPHeart(wr *bufio.Writer, online int32) (err error)

WriteTCPHeart write TCP heartbeat with room online.

func (*Proto) WriteTo

func (p *Proto) WriteTo(b *bytes.Writer)

WriteTo write a proto to bytes writer.

func (*Proto) WriteWebsocket

func (p *Proto) WriteWebsocket(ws *websocket.Conn) (err error)

WriteWebsocket write a proto to websocket connection.

func (*Proto) WriteWebsocket2

func (p *Proto) WriteWebsocket2(ws *gws.Conn) (err error)

WriteWebsocket write a proto to websocket connection.

func (*Proto) WriteWebsocketHeart

func (p *Proto) WriteWebsocketHeart(wr *websocket.Conn, online int32) (err error)

WriteWebsocketHeart write websocket heartbeat with room online.

type PushMsgReply

type PushMsgReply struct {
	Index map[string]int32 `` /* 152-byte string literal not displayed */
	// contains filtered or unexported fields
}

func (*PushMsgReply) Descriptor deprecated

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

Deprecated: Use PushMsgReply.ProtoReflect.Descriptor instead.

func (*PushMsgReply) GetIndex

func (x *PushMsgReply) GetIndex() map[string]int32

func (*PushMsgReply) ProtoMessage

func (*PushMsgReply) ProtoMessage()

func (*PushMsgReply) ProtoReflect

func (x *PushMsgReply) ProtoReflect() protoreflect.Message

func (*PushMsgReply) Reset

func (x *PushMsgReply) Reset()

func (*PushMsgReply) String

func (x *PushMsgReply) String() string

type PushMsgReq

type PushMsgReq struct {
	Keys    []string `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"`
	ProtoOp int32    `protobuf:"varint,2,opt,name=protoOp,proto3" json:"protoOp,omitempty"`
	Proto   *Proto   `protobuf:"bytes,3,opt,name=proto,proto3" json:"proto,omitempty"`
	// contains filtered or unexported fields
}

func (*PushMsgReq) Descriptor deprecated

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

Deprecated: Use PushMsgReq.ProtoReflect.Descriptor instead.

func (*PushMsgReq) GetKeys

func (x *PushMsgReq) GetKeys() []string

func (*PushMsgReq) GetProto

func (x *PushMsgReq) GetProto() *Proto

func (*PushMsgReq) GetProtoOp

func (x *PushMsgReq) GetProtoOp() int32

func (*PushMsgReq) ProtoMessage

func (*PushMsgReq) ProtoMessage()

func (*PushMsgReq) ProtoReflect

func (x *PushMsgReq) ProtoReflect() protoreflect.Message

func (*PushMsgReq) Reset

func (x *PushMsgReq) Reset()

func (*PushMsgReq) String

func (x *PushMsgReq) String() string

type SyncMsg

type SyncMsg struct {
	LogId int64 `protobuf:"varint,1,opt,name=logId,proto3" json:"logId,omitempty"`
	// contains filtered or unexported fields
}

Proto 中 Op 为 SyncMsgReply 时, body 必须可以反序列化为 SyncMsg

func (*SyncMsg) Descriptor deprecated

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

Deprecated: Use SyncMsg.ProtoReflect.Descriptor instead.

func (*SyncMsg) GetLogId

func (x *SyncMsg) GetLogId() int64

func (*SyncMsg) ProtoMessage

func (*SyncMsg) ProtoMessage()

func (*SyncMsg) ProtoReflect

func (x *SyncMsg) ProtoReflect() protoreflect.Message

func (*SyncMsg) Reset

func (x *SyncMsg) Reset()

func (*SyncMsg) String

func (x *SyncMsg) String() string

type UnimplementedCometServer

type UnimplementedCometServer struct {
}

UnimplementedCometServer must be embedded to have forward compatible implementations.

func (UnimplementedCometServer) Broadcast

func (UnimplementedCometServer) BroadcastGroup

func (UnimplementedCometServer) DelGroups

func (UnimplementedCometServer) JoinGroups

func (UnimplementedCometServer) LeaveGroups

func (UnimplementedCometServer) PushMsg

type UnsafeCometServer

type UnsafeCometServer interface {
	// contains filtered or unexported methods
}

UnsafeCometServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to CometServer will result in compilation errors.

Jump to

Keyboard shortcuts

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