rpc

package
v0.0.0-...-325de3d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 14 Imported by: 0

README

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./internal/lim/rpc/service.proto

Documentation

Index

Constants

View Source
const (
	// CMDTypeForwardSendPacket 转发发送包
	CMDTypeForwardSendPacket = 1001
)

Variables

View Source
var (
	CMDType_name = map[int32]string{
		0: "None",
		1: "ForwardSendPacket",
		2: "ForwardRecvPacket",
		3: "GetSubscribers",
		4: "GenChannelMessageSeq",
	}
	CMDType_value = map[string]int32{
		"None":                 0,
		"ForwardSendPacket":    1,
		"ForwardRecvPacket":    2,
		"GetSubscribers":       3,
		"GenChannelMessageSeq": 4,
	}
)

Enum value maps for CMDType.

View Source
var (
	Status_name = map[int32]string{
		0: "Error",
		1: "Success",
	}
	Status_value = map[string]int32{
		"Error":   0,
		"Success": 1,
	}
)

Enum value maps for Status.

View Source
var File_internal_lim_rpc_service_proto protoreflect.FileDescriptor
View Source
var NodeService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "rpc.NodeService",
	HandlerType: (*NodeServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "SendCMD",
			Handler:    _NodeService_SendCMD_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "internal/lim/rpc/service.proto",
}

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

Functions

func RegisterNodeServiceServer

func RegisterNodeServiceServer(s grpc.ServiceRegistrar, srv NodeServiceServer)

Types

type CMDEvent

type CMDEvent interface {
	// 收到发送包
	OnSendPacket(fromUID string, deviceFlag lmproto.DeviceFlag, sendPacket *lmproto.SendPacket) (messageID int64, messageSeq uint32, reasonCode lmproto.ReasonCode, err error)
	// 收到接受包
	OnRecvPacket(deviceFlag lmproto.DeviceFlag, recvPacket *lmproto.RecvPacket, users []string) error
	// 获取频道订阅者
	OnGetSubscribers(channelID string, channelType uint8) ([]string, error)
	// 获取频道的消息序号
	OnGetChannelMessageSeq(channelID string, channelType uint8) (uint32, error)
}

CMDEvent cmd事件

type CMDReq

type CMDReq struct {
	Cmd  CMDType `protobuf:"varint,1,opt,name=cmd,proto3,enum=rpc.CMDType" json:"cmd,omitempty"`
	Data []byte  `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	// contains filtered or unexported fields
}

func (*CMDReq) Descriptor deprecated

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

Deprecated: Use CMDReq.ProtoReflect.Descriptor instead.

func (*CMDReq) GetCmd

func (x *CMDReq) GetCmd() CMDType

func (*CMDReq) GetData

func (x *CMDReq) GetData() []byte

func (*CMDReq) ProtoMessage

func (*CMDReq) ProtoMessage()

func (*CMDReq) ProtoReflect

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

func (*CMDReq) Reset

func (x *CMDReq) Reset()

func (*CMDReq) String

func (x *CMDReq) String() string

type CMDResp

type CMDResp struct {
	Status Status `protobuf:"varint,1,opt,name=status,proto3,enum=rpc.Status" json:"status,omitempty"` // 请求唯一ID
	Data   []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`                      // 返回数据
	// contains filtered or unexported fields
}

func (*CMDResp) Descriptor deprecated

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

Deprecated: Use CMDResp.ProtoReflect.Descriptor instead.

func (*CMDResp) GetData

func (x *CMDResp) GetData() []byte

func (*CMDResp) GetStatus

func (x *CMDResp) GetStatus() Status

func (*CMDResp) ProtoMessage

func (*CMDResp) ProtoMessage()

func (*CMDResp) ProtoReflect

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

func (*CMDResp) Reset

func (x *CMDResp) Reset()

func (*CMDResp) String

func (x *CMDResp) String() string

type CMDType

type CMDType int32
const (
	CMDType_None                 CMDType = 0
	CMDType_ForwardSendPacket    CMDType = 1 // 转发发送包
	CMDType_ForwardRecvPacket    CMDType = 2 // 转发接受包
	CMDType_GetSubscribers       CMDType = 3 // 获取频道订阅者
	CMDType_GenChannelMessageSeq CMDType = 4 // 获取频道的序号
)

func (CMDType) Descriptor

func (CMDType) Descriptor() protoreflect.EnumDescriptor

func (CMDType) Enum

func (x CMDType) Enum() *CMDType

func (CMDType) EnumDescriptor deprecated

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

Deprecated: Use CMDType.Descriptor instead.

func (CMDType) Number

func (x CMDType) Number() protoreflect.EnumNumber

func (CMDType) String

func (x CMDType) String() string

func (CMDType) Type

func (CMDType) Type() protoreflect.EnumType

type ForwardRecvPacketReq

type ForwardRecvPacketReq struct {
	No             string   `protobuf:"bytes,1,opt,name=no,proto3" json:"no,omitempty"`                          // 此次请求的唯一编号
	Users          []string `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"`                    // 用户
	Message        []byte   `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`                // 对应的消息
	FromDeviceFlag int32    `protobuf:"varint,4,opt,name=fromDeviceFlag,proto3" json:"fromDeviceFlag,omitempty"` // 发送者的设备标记
	// contains filtered or unexported fields
}

func (*ForwardRecvPacketReq) Descriptor deprecated

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

Deprecated: Use ForwardRecvPacketReq.ProtoReflect.Descriptor instead.

func (*ForwardRecvPacketReq) GetFromDeviceFlag

func (x *ForwardRecvPacketReq) GetFromDeviceFlag() int32

func (*ForwardRecvPacketReq) GetMessage

func (x *ForwardRecvPacketReq) GetMessage() []byte

func (*ForwardRecvPacketReq) GetNo

func (x *ForwardRecvPacketReq) GetNo() string

func (*ForwardRecvPacketReq) GetUsers

func (x *ForwardRecvPacketReq) GetUsers() []string

func (*ForwardRecvPacketReq) ProtoMessage

func (*ForwardRecvPacketReq) ProtoMessage()

func (*ForwardRecvPacketReq) ProtoReflect

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

func (*ForwardRecvPacketReq) Reset

func (x *ForwardRecvPacketReq) Reset()

func (*ForwardRecvPacketReq) String

func (x *ForwardRecvPacketReq) String() string

type ForwardSendPacketReq

type ForwardSendPacketReq struct {
	SendPacket     []byte `protobuf:"bytes,1,opt,name=sendPacket,proto3" json:"sendPacket,omitempty"`          // 发送包
	FromUID        string `protobuf:"bytes,2,opt,name=fromUID,proto3" json:"fromUID,omitempty"`                // 发送者UID
	FromDeviceFlag int32  `protobuf:"varint,3,opt,name=fromDeviceFlag,proto3" json:"fromDeviceFlag,omitempty"` // 发送者的设备标记
	// contains filtered or unexported fields
}

func (*ForwardSendPacketReq) Descriptor deprecated

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

Deprecated: Use ForwardSendPacketReq.ProtoReflect.Descriptor instead.

func (*ForwardSendPacketReq) GetFromDeviceFlag

func (x *ForwardSendPacketReq) GetFromDeviceFlag() int32

func (*ForwardSendPacketReq) GetFromUID

func (x *ForwardSendPacketReq) GetFromUID() string

func (*ForwardSendPacketReq) GetSendPacket

func (x *ForwardSendPacketReq) GetSendPacket() []byte

func (*ForwardSendPacketReq) ProtoMessage

func (*ForwardSendPacketReq) ProtoMessage()

func (*ForwardSendPacketReq) ProtoReflect

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

func (*ForwardSendPacketReq) Reset

func (x *ForwardSendPacketReq) Reset()

func (*ForwardSendPacketReq) String

func (x *ForwardSendPacketReq) String() string

type ForwardSendPacketResp

type ForwardSendPacketResp struct {
	MessageID  int64 `protobuf:"varint,1,opt,name=messageID,proto3" json:"messageID,omitempty"`   // 消息唯一ID
	ReasonCode int32 `protobuf:"varint,2,opt,name=reasonCode,proto3" json:"reasonCode,omitempty"` // 发送原因码
	MessageSeq int32 `protobuf:"varint,3,opt,name=messageSeq,proto3" json:"messageSeq,omitempty"` // 消息编号
	// contains filtered or unexported fields
}

func (*ForwardSendPacketResp) Descriptor deprecated

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

Deprecated: Use ForwardSendPacketResp.ProtoReflect.Descriptor instead.

func (*ForwardSendPacketResp) GetMessageID

func (x *ForwardSendPacketResp) GetMessageID() int64

func (*ForwardSendPacketResp) GetMessageSeq

func (x *ForwardSendPacketResp) GetMessageSeq() int32

func (*ForwardSendPacketResp) GetReasonCode

func (x *ForwardSendPacketResp) GetReasonCode() int32

func (*ForwardSendPacketResp) ProtoMessage

func (*ForwardSendPacketResp) ProtoMessage()

func (*ForwardSendPacketResp) ProtoReflect

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

func (*ForwardSendPacketResp) Reset

func (x *ForwardSendPacketResp) Reset()

func (*ForwardSendPacketResp) String

func (x *ForwardSendPacketResp) String() string

type GetChannelMessageSeqReq

type GetChannelMessageSeqReq struct {
	ChannelID   string `protobuf:"bytes,1,opt,name=channelID,proto3" json:"channelID,omitempty"`
	ChannelType int32  `protobuf:"varint,2,opt,name=channelType,proto3" json:"channelType,omitempty"`
	// contains filtered or unexported fields
}

func (*GetChannelMessageSeqReq) Descriptor deprecated

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

Deprecated: Use GetChannelMessageSeqReq.ProtoReflect.Descriptor instead.

func (*GetChannelMessageSeqReq) GetChannelID

func (x *GetChannelMessageSeqReq) GetChannelID() string

func (*GetChannelMessageSeqReq) GetChannelType

func (x *GetChannelMessageSeqReq) GetChannelType() int32

func (*GetChannelMessageSeqReq) ProtoMessage

func (*GetChannelMessageSeqReq) ProtoMessage()

func (*GetChannelMessageSeqReq) ProtoReflect

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

func (*GetChannelMessageSeqReq) Reset

func (x *GetChannelMessageSeqReq) Reset()

func (*GetChannelMessageSeqReq) String

func (x *GetChannelMessageSeqReq) String() string

type GetChannelMessageSeqResp

type GetChannelMessageSeqResp struct {
	MessageSeq int32 `protobuf:"varint,1,opt,name=messageSeq,proto3" json:"messageSeq,omitempty"` // 消息编号
	// contains filtered or unexported fields
}

func (*GetChannelMessageSeqResp) Descriptor deprecated

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

Deprecated: Use GetChannelMessageSeqResp.ProtoReflect.Descriptor instead.

func (*GetChannelMessageSeqResp) GetMessageSeq

func (x *GetChannelMessageSeqResp) GetMessageSeq() int32

func (*GetChannelMessageSeqResp) ProtoMessage

func (*GetChannelMessageSeqResp) ProtoMessage()

func (*GetChannelMessageSeqResp) ProtoReflect

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

func (*GetChannelMessageSeqResp) Reset

func (x *GetChannelMessageSeqResp) Reset()

func (*GetChannelMessageSeqResp) String

func (x *GetChannelMessageSeqResp) String() string

type GetSubscribersReq

type GetSubscribersReq struct {
	ChannelID   string `protobuf:"bytes,1,opt,name=channelID,proto3" json:"channelID,omitempty"`
	ChannelType int32  `protobuf:"varint,2,opt,name=channelType,proto3" json:"channelType,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSubscribersReq) Descriptor deprecated

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

Deprecated: Use GetSubscribersReq.ProtoReflect.Descriptor instead.

func (*GetSubscribersReq) GetChannelID

func (x *GetSubscribersReq) GetChannelID() string

func (*GetSubscribersReq) GetChannelType

func (x *GetSubscribersReq) GetChannelType() int32

func (*GetSubscribersReq) ProtoMessage

func (*GetSubscribersReq) ProtoMessage()

func (*GetSubscribersReq) ProtoReflect

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

func (*GetSubscribersReq) Reset

func (x *GetSubscribersReq) Reset()

func (*GetSubscribersReq) String

func (x *GetSubscribersReq) String() string

type GetSubscribersResp

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

func (*GetSubscribersResp) Descriptor deprecated

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

Deprecated: Use GetSubscribersResp.ProtoReflect.Descriptor instead.

func (*GetSubscribersResp) GetSubscribers

func (x *GetSubscribersResp) GetSubscribers() []string

func (*GetSubscribersResp) ProtoMessage

func (*GetSubscribersResp) ProtoMessage()

func (*GetSubscribersResp) ProtoReflect

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

func (*GetSubscribersResp) Reset

func (x *GetSubscribersResp) Reset()

func (*GetSubscribersResp) String

func (x *GetSubscribersResp) String() string

type NodeServiceClient

type NodeServiceClient interface {
	// 转发
	SendCMD(ctx context.Context, in *CMDReq, opts ...grpc.CallOption) (*CMDResp, error)
}

NodeServiceClient is the client API for NodeService 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.

type NodeServiceServer

type NodeServiceServer interface {
	// 转发
	SendCMD(context.Context, *CMDReq) (*CMDResp, error)
	// contains filtered or unexported methods
}

NodeServiceServer is the server API for NodeService service. All implementations must embed UnimplementedNodeServiceServer for forward compatibility

type Server

type Server struct {
	limlog.Log
	// contains filtered or unexported fields
}

Server rpc服务

func NewServer

func NewServer(proto lmproto.Protocol, event CMDEvent, addr string) *Server

NewServer NewServer

func (*Server) Start

func (s *Server) Start()

Start 开启rpc服务

type Status

type Status int32
const (
	Status_Error   Status = 0
	Status_Success Status = 1
)

func (Status) Descriptor

func (Status) Descriptor() protoreflect.EnumDescriptor

func (Status) Enum

func (x Status) Enum() *Status

func (Status) EnumDescriptor deprecated

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

Deprecated: Use Status.Descriptor instead.

func (Status) Number

func (x Status) Number() protoreflect.EnumNumber

func (Status) String

func (x Status) String() string

func (Status) Type

func (Status) Type() protoreflect.EnumType

type UnimplementedNodeServiceServer

type UnimplementedNodeServiceServer struct {
}

UnimplementedNodeServiceServer must be embedded to have forward compatible implementations.

func (UnimplementedNodeServiceServer) SendCMD

type UnsafeNodeServiceServer

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

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

Jump to

Keyboard shortcuts

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