saas-smartAi通信协议标准库
gongshangguo
2022-03-02 cb8a046f1d84198b6bbddb1481667b905ea522bf
业务端口类型
3个文件已修改
397 ■■■■ 已修改文件
aiotProto/aiot/aiot_business.pb.go 287 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aiotProto/aiot/aiot_business.pb.micro.go 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aiotProto/aiot/aiot_business.proto 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aiotProto/aiot/aiot_business.pb.go
@@ -20,21 +20,24 @@
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// 请求类型
type RequestType int32
const (
    RequestType_Async RequestType = 0
    RequestType_sync  RequestType = 1
    // 同步请求 默认
    RequestType_sync RequestType = 0
    // 异步请求
    RequestType_Async RequestType = 1
)
var RequestType_name = map[int32]string{
    0: "Async",
    1: "sync",
    0: "sync",
    1: "Async",
}
var RequestType_value = map[string]int32{
    "Async": 0,
    "sync":  1,
    "sync":  0,
    "Async": 1,
}
func (x RequestType) String() string {
@@ -46,79 +49,221 @@
}
// 请求的body体
type BusinessReq struct {
    Topic                string      `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
    Authorization        string      `protobuf:"bytes,2,opt,name=authorization,proto3" json:"authorization,omitempty"`
    Ip                   string      `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"`
    Port                 string      `protobuf:"bytes,4,opt,name=port,proto3" json:"port,omitempty"`
    Type                 RequestType `protobuf:"varint,5,opt,name=type,proto3,enum=aiot.RequestType" json:"type,omitempty"`
    Req                  []byte      `protobuf:"bytes,6,opt,name=req,proto3" json:"req,omitempty"`
    XXX_NoUnkeyedLiteral struct{}    `json:"-"`
    XXX_unrecognized     []byte      `json:"-"`
    XXX_sizecache        int32       `json:"-"`
type NodeReq struct {
    // 请求的topic url
    Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
    // token
    Authorization string `protobuf:"bytes,2,opt,name=authorization,proto3" json:"authorization,omitempty"`
    // 请求指向的ip
    Ip string `protobuf:"bytes,3,opt,name=ip,proto3" json:"ip,omitempty"`
    // 请求的端口 保留字段
    Port string `protobuf:"bytes,4,opt,name=port,proto3" json:"port,omitempty"`
    // 请求的同步/异步类型
    SyncType RequestType `protobuf:"varint,5,opt,name=syncType,proto3,enum=aiot.RequestType" json:"syncType,omitempty"`
    // 请求业务参数
    Req                  []byte   `protobuf:"bytes,6,opt,name=req,proto3" json:"req,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}
func (m *BusinessReq) Reset()         { *m = BusinessReq{} }
func (m *BusinessReq) String() string { return proto.CompactTextString(m) }
func (*BusinessReq) ProtoMessage()    {}
func (*BusinessReq) Descriptor() ([]byte, []int) {
func (m *NodeReq) Reset()         { *m = NodeReq{} }
func (m *NodeReq) String() string { return proto.CompactTextString(m) }
func (*NodeReq) ProtoMessage()    {}
func (*NodeReq) Descriptor() ([]byte, []int) {
    return fileDescriptor_29eca6d4b33e7fd8, []int{0}
}
func (m *BusinessReq) XXX_Unmarshal(b []byte) error {
    return xxx_messageInfo_BusinessReq.Unmarshal(m, b)
func (m *NodeReq) XXX_Unmarshal(b []byte) error {
    return xxx_messageInfo_NodeReq.Unmarshal(m, b)
}
func (m *BusinessReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    return xxx_messageInfo_BusinessReq.Marshal(b, m, deterministic)
func (m *NodeReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    return xxx_messageInfo_NodeReq.Marshal(b, m, deterministic)
}
func (m *BusinessReq) XXX_Merge(src proto.Message) {
    xxx_messageInfo_BusinessReq.Merge(m, src)
func (m *NodeReq) XXX_Merge(src proto.Message) {
    xxx_messageInfo_NodeReq.Merge(m, src)
}
func (m *BusinessReq) XXX_Size() int {
    return xxx_messageInfo_BusinessReq.Size(m)
func (m *NodeReq) XXX_Size() int {
    return xxx_messageInfo_NodeReq.Size(m)
}
func (m *BusinessReq) XXX_DiscardUnknown() {
    xxx_messageInfo_BusinessReq.DiscardUnknown(m)
func (m *NodeReq) XXX_DiscardUnknown() {
    xxx_messageInfo_NodeReq.DiscardUnknown(m)
}
var xxx_messageInfo_BusinessReq proto.InternalMessageInfo
var xxx_messageInfo_NodeReq proto.InternalMessageInfo
func (m *BusinessReq) GetTopic() string {
func (m *NodeReq) GetTopic() string {
    if m != nil {
        return m.Topic
    }
    return ""
}
func (m *BusinessReq) GetAuthorization() string {
func (m *NodeReq) GetAuthorization() string {
    if m != nil {
        return m.Authorization
    }
    return ""
}
func (m *BusinessReq) GetIp() string {
func (m *NodeReq) GetIp() string {
    if m != nil {
        return m.Ip
    }
    return ""
}
func (m *BusinessReq) GetPort() string {
func (m *NodeReq) GetPort() string {
    if m != nil {
        return m.Port
    }
    return ""
}
func (m *BusinessReq) GetType() RequestType {
func (m *NodeReq) GetSyncType() RequestType {
    if m != nil {
        return m.Type
        return m.SyncType
    }
    return RequestType_Async
    return RequestType_sync
}
func (m *BusinessReq) GetReq() []byte {
func (m *NodeReq) GetReq() []byte {
    if m != nil {
        return m.Req
    }
    return nil
}
// 集群请求参数
type ClusterReq struct {
    // 集群ID
    ClusterId string `protobuf:"bytes,1,opt,name=ClusterId,proto3" json:"ClusterId,omitempty"`
    // token
    Authorization string `protobuf:"bytes,2,opt,name=authorization,proto3" json:"authorization,omitempty"`
    // 请求的同步/异步类型
    SyncType RequestType `protobuf:"varint,3,opt,name=syncType,proto3,enum=aiot.RequestType" json:"syncType,omitempty"`
    // 请求业务参数
    Req                  []byte   `protobuf:"bytes,4,opt,name=req,proto3" json:"req,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}
func (m *ClusterReq) Reset()         { *m = ClusterReq{} }
func (m *ClusterReq) String() string { return proto.CompactTextString(m) }
func (*ClusterReq) ProtoMessage()    {}
func (*ClusterReq) Descriptor() ([]byte, []int) {
    return fileDescriptor_29eca6d4b33e7fd8, []int{1}
}
func (m *ClusterReq) XXX_Unmarshal(b []byte) error {
    return xxx_messageInfo_ClusterReq.Unmarshal(m, b)
}
func (m *ClusterReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    return xxx_messageInfo_ClusterReq.Marshal(b, m, deterministic)
}
func (m *ClusterReq) XXX_Merge(src proto.Message) {
    xxx_messageInfo_ClusterReq.Merge(m, src)
}
func (m *ClusterReq) XXX_Size() int {
    return xxx_messageInfo_ClusterReq.Size(m)
}
func (m *ClusterReq) XXX_DiscardUnknown() {
    xxx_messageInfo_ClusterReq.DiscardUnknown(m)
}
var xxx_messageInfo_ClusterReq proto.InternalMessageInfo
func (m *ClusterReq) GetClusterId() string {
    if m != nil {
        return m.ClusterId
    }
    return ""
}
func (m *ClusterReq) GetAuthorization() string {
    if m != nil {
        return m.Authorization
    }
    return ""
}
func (m *ClusterReq) GetSyncType() RequestType {
    if m != nil {
        return m.SyncType
    }
    return RequestType_sync
}
func (m *ClusterReq) GetReq() []byte {
    if m != nil {
        return m.Req
    }
    return nil
}
// 设备列表请求参数
type NodesReq struct {
    // 设备列表ID
    NodeIds []string `protobuf:"bytes,1,rep,name=NodeIds,proto3" json:"NodeIds,omitempty"`
    // token
    Authorization string `protobuf:"bytes,2,opt,name=authorization,proto3" json:"authorization,omitempty"`
    // 请求的同步/异步类型
    SyncType RequestType `protobuf:"varint,3,opt,name=syncType,proto3,enum=aiot.RequestType" json:"syncType,omitempty"`
    // 请求业务参数
    Req                  []byte   `protobuf:"bytes,4,opt,name=req,proto3" json:"req,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}
func (m *NodesReq) Reset()         { *m = NodesReq{} }
func (m *NodesReq) String() string { return proto.CompactTextString(m) }
func (*NodesReq) ProtoMessage()    {}
func (*NodesReq) Descriptor() ([]byte, []int) {
    return fileDescriptor_29eca6d4b33e7fd8, []int{2}
}
func (m *NodesReq) XXX_Unmarshal(b []byte) error {
    return xxx_messageInfo_NodesReq.Unmarshal(m, b)
}
func (m *NodesReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
    return xxx_messageInfo_NodesReq.Marshal(b, m, deterministic)
}
func (m *NodesReq) XXX_Merge(src proto.Message) {
    xxx_messageInfo_NodesReq.Merge(m, src)
}
func (m *NodesReq) XXX_Size() int {
    return xxx_messageInfo_NodesReq.Size(m)
}
func (m *NodesReq) XXX_DiscardUnknown() {
    xxx_messageInfo_NodesReq.DiscardUnknown(m)
}
var xxx_messageInfo_NodesReq proto.InternalMessageInfo
func (m *NodesReq) GetNodeIds() []string {
    if m != nil {
        return m.NodeIds
    }
    return nil
}
func (m *NodesReq) GetAuthorization() string {
    if m != nil {
        return m.Authorization
    }
    return ""
}
func (m *NodesReq) GetSyncType() RequestType {
    if m != nil {
        return m.SyncType
    }
    return RequestType_sync
}
func (m *NodesReq) GetReq() []byte {
    if m != nil {
        return m.Req
    }
@@ -127,9 +272,13 @@
// 响应的body体
type BusinessReply struct {
    Code                 int32    `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
    Msg                  string   `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
    Success              bool     `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`
    // 返回的错误码
    Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
    // 错误信息
    Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
    // 是否success
    Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`
    // 返回结果
    Data                 []byte   `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
@@ -140,7 +289,7 @@
func (m *BusinessReply) String() string { return proto.CompactTextString(m) }
func (*BusinessReply) ProtoMessage()    {}
func (*BusinessReply) Descriptor() ([]byte, []int) {
    return fileDescriptor_29eca6d4b33e7fd8, []int{1}
    return fileDescriptor_29eca6d4b33e7fd8, []int{3}
}
func (m *BusinessReply) XXX_Unmarshal(b []byte) error {
@@ -191,7 +340,9 @@
func init() {
    proto.RegisterEnum("aiot.RequestType", RequestType_name, RequestType_value)
    proto.RegisterType((*BusinessReq)(nil), "aiot.BusinessReq")
    proto.RegisterType((*NodeReq)(nil), "aiot.NodeReq")
    proto.RegisterType((*ClusterReq)(nil), "aiot.ClusterReq")
    proto.RegisterType((*NodesReq)(nil), "aiot.NodesReq")
    proto.RegisterType((*BusinessReply)(nil), "aiot.BusinessReply")
}
@@ -200,25 +351,31 @@
}
var fileDescriptor_29eca6d4b33e7fd8 = []byte{
    // 314 bytes of a gzipped FileDescriptorProto
    0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0x41, 0x4f, 0x02, 0x31,
    0x10, 0x85, 0x59, 0xd8, 0x45, 0x98, 0x05, 0x02, 0x83, 0x87, 0x86, 0x13, 0xd9, 0x68, 0x42, 0x3c,
    0x60, 0x82, 0x07, 0xcf, 0x78, 0xf1, 0x6a, 0x8a, 0x77, 0xb3, 0x94, 0x89, 0x36, 0x81, 0x6d, 0xd9,
    0x76, 0x35, 0xeb, 0x0f, 0xf2, 0x77, 0x9a, 0x0e, 0x10, 0x91, 0xdb, 0x9b, 0xf7, 0x3a, 0x93, 0xaf,
    0x33, 0x30, 0xce, 0xb5, 0xf1, 0x6f, 0xeb, 0xca, 0xe9, 0x82, 0x9c, 0x9b, 0xdb, 0xd2, 0x78, 0x83,
    0x71, 0x30, 0x27, 0x23, 0x8e, 0x94, 0xd9, 0xed, 0x4c, 0x71, 0x08, 0xb2, 0x9f, 0x08, 0xd2, 0xa7,
    0xe3, 0x5b, 0x49, 0x7b, 0xbc, 0x86, 0xc4, 0x1b, 0xab, 0x95, 0x88, 0xa6, 0xd1, 0xac, 0x2b, 0x0f,
    0x05, 0xde, 0x40, 0x3f, 0xaf, 0xfc, 0x87, 0x29, 0xf5, 0x77, 0xee, 0xb5, 0x29, 0x44, 0x93, 0xd3,
    0xff, 0x26, 0x0e, 0xa0, 0xa9, 0xad, 0x68, 0x71, 0xd4, 0xd4, 0x16, 0x11, 0x62, 0x6b, 0x4a, 0x2f,
    0x62, 0x76, 0x58, 0xe3, 0x2d, 0xc4, 0xbe, 0xb6, 0x24, 0x92, 0x69, 0x34, 0x1b, 0x2c, 0x46, 0xf3,
    0x40, 0x34, 0x97, 0xb4, 0xaf, 0xc8, 0xf9, 0xd7, 0xda, 0x92, 0xe4, 0x18, 0x87, 0xd0, 0x2a, 0x69,
    0x2f, 0xda, 0xd3, 0x68, 0xd6, 0x93, 0x41, 0x66, 0x0a, 0xfa, 0x7f, 0x9c, 0x76, 0x5b, 0x87, 0xe9,
    0xca, 0x6c, 0x88, 0x41, 0x13, 0xc9, 0x3a, 0xb4, 0xed, 0xdc, 0xfb, 0x91, 0x2e, 0x48, 0x14, 0x70,
    0xe5, 0x2a, 0xa5, 0xc8, 0x39, 0x06, 0xeb, 0xc8, 0x53, 0x19, 0xfa, 0x37, 0xb9, 0xcf, 0x99, 0xae,
    0x27, 0x59, 0xdf, 0x65, 0x90, 0x9e, 0xb1, 0x60, 0x17, 0x92, 0xa5, 0xab, 0x0b, 0x35, 0x6c, 0x60,
    0x07, 0x62, 0x56, 0xd1, 0xe2, 0x0b, 0xd2, 0xa5, 0x36, 0x7e, 0x45, 0xe5, 0xa7, 0x56, 0x84, 0x8f,
    0x90, 0x3e, 0x93, 0x3f, 0xa1, 0xe1, 0xf1, 0x47, 0x67, 0x2b, 0x9d, 0x8c, 0x2f, 0x2d, 0xbb, 0xad,
    0xb3, 0x06, 0xde, 0x43, 0xba, 0xa2, 0x62, 0x13, 0x66, 0x85, 0xc5, 0x0f, 0x0e, 0xaf, 0x5e, 0xc2,
    0x55, 0x94, 0xd9, 0x4e, 0x2e, 0xea, 0xac, 0xb1, 0x6e, 0xf3, 0xc5, 0x1e, 0x7e, 0x03, 0x00, 0x00,
    0xff, 0xff, 0x61, 0x52, 0x68, 0x6c, 0xe1, 0x01, 0x00, 0x00,
    // 412 bytes of a gzipped FileDescriptorProto
    0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x93, 0xb1, 0xce, 0xd3, 0x30,
    0x10, 0xc7, 0xeb, 0x26, 0xf9, 0x48, 0xae, 0xa4, 0xea, 0xe7, 0x8f, 0xc1, 0xaa, 0x18, 0xa2, 0x88,
    0x21, 0x42, 0xa2, 0x48, 0x85, 0x81, 0xf5, 0x83, 0xa9, 0x0b, 0x42, 0x6e, 0x77, 0x94, 0x3a, 0x16,
    0x58, 0x6a, 0xe3, 0x34, 0x76, 0x90, 0xca, 0x2b, 0x30, 0xf1, 0x1a, 0x3c, 0x16, 0x4f, 0x82, 0xce,
    0x4e, 0x68, 0x8b, 0x54, 0xa9, 0x13, 0xdb, 0xfd, 0xef, 0x7c, 0xfd, 0xff, 0x7a, 0x77, 0x81, 0x87,
    0x52, 0x69, 0xfb, 0x79, 0xdb, 0x19, 0x55, 0x4b, 0x63, 0x16, 0x4d, 0xab, 0xad, 0xa6, 0x21, 0x26,
    0xe7, 0xf7, 0xae, 0x24, 0xf4, 0x7e, 0xaf, 0x6b, 0x5f, 0xc8, 0x7f, 0x11, 0x78, 0xf2, 0x51, 0x57,
    0x92, 0xcb, 0x03, 0x7d, 0x06, 0x91, 0xd5, 0x8d, 0x12, 0x8c, 0x64, 0xa4, 0x48, 0xb8, 0x17, 0xf4,
    0x05, 0xa4, 0x65, 0x67, 0xbf, 0xea, 0x56, 0x7d, 0x2f, 0xad, 0xd2, 0x35, 0x1b, 0xbb, 0xea, 0x65,
    0x92, 0x4e, 0x61, 0xac, 0x1a, 0x16, 0xb8, 0xd2, 0x58, 0x35, 0x94, 0x42, 0xd8, 0xe8, 0xd6, 0xb2,
    0xd0, 0x65, 0x5c, 0x4c, 0x5f, 0x41, 0x6c, 0x8e, 0xb5, 0xd8, 0x1c, 0x1b, 0xc9, 0xa2, 0x8c, 0x14,
    0xd3, 0xe5, 0xfd, 0x02, 0x89, 0x16, 0x5c, 0x1e, 0x3a, 0x69, 0x2c, 0x16, 0xf8, 0xdf, 0x27, 0x74,
    0x06, 0x41, 0x2b, 0x0f, 0xec, 0x2e, 0x23, 0xc5, 0x53, 0x8e, 0x61, 0xfe, 0x93, 0x00, 0x7c, 0xd8,
    0x75, 0xc6, 0xca, 0x16, 0x79, 0x9f, 0x43, 0xd2, 0xab, 0x55, 0xd5, 0x33, 0x9f, 0x12, 0x37, 0x72,
    0x9f, 0x33, 0x05, 0x37, 0x33, 0x85, 0x27, 0xa6, 0x1f, 0x04, 0x62, 0x1c, 0xa0, 0x41, 0x22, 0xe6,
    0x87, 0xb9, 0xaa, 0x0c, 0x23, 0x59, 0x50, 0x24, 0x7c, 0x90, 0xff, 0x8b, 0x46, 0x40, 0xfa, 0xbe,
    0xdf, 0x3c, 0x97, 0xcd, 0xee, 0x88, 0x7b, 0x10, 0xba, 0x92, 0x6e, 0x3c, 0x11, 0x77, 0x31, 0xb6,
    0xed, 0xcd, 0x97, 0x9e, 0x00, 0x43, 0xe4, 0x36, 0x9d, 0x10, 0xd2, 0x18, 0x67, 0x1b, 0xf3, 0x41,
    0x62, 0x7f, 0x55, 0xda, 0xb2, 0xf7, 0x70, 0xf1, 0xcb, 0x1c, 0x26, 0x67, 0x3c, 0x34, 0x86, 0x10,
    0x89, 0x66, 0x23, 0x9a, 0x40, 0xf4, 0xe8, 0x42, 0xb2, 0xfc, 0x4d, 0x60, 0xf2, 0xa8, 0xb4, 0x5d,
    0xcb, 0xf6, 0x9b, 0x12, 0x92, 0x2e, 0x01, 0xd6, 0xb2, 0xae, 0x36, 0x1a, 0x07, 0x42, 0x53, 0xff,
    0xaf, 0xfa, 0xc3, 0x9b, 0x3f, 0x78, 0x79, 0x41, 0x9e, 0x8f, 0xe8, 0x6b, 0x98, 0x60, 0x0f, 0xfe,
    0x0c, 0x0e, 0x77, 0xea, 0x5f, 0x7d, 0xc2, 0xbb, 0x15, 0x7a, 0x37, 0xff, 0x47, 0xe7, 0x23, 0xfa,
    0x0e, 0x52, 0x6f, 0xd2, 0x5f, 0x01, 0x9d, 0xf9, 0x27, 0xa7, 0x9b, 0xb9, 0x66, 0xf5, 0xd6, 0x5b,
    0x79, 0x3c, 0x33, 0x58, 0x0d, 0x7b, 0xbd, 0xd2, 0xb5, 0xbd, 0x73, 0xdf, 0xd0, 0x9b, 0x3f, 0x01,
    0x00, 0x00, 0xff, 0xff, 0xe4, 0x20, 0xab, 0x58, 0x73, 0x03, 0x00, 0x00,
}
aiotProto/aiot/aiot_business.pb.micro.go
@@ -34,8 +34,14 @@
// Client API for AiotService service
type AiotService interface {
    GetBusiness(ctx context.Context, in *BusinessReq, opts ...client.CallOption) (*BusinessReply, error)
    // 发送指向单个设备的请求
    SendToNode(ctx context.Context, in *NodeReq, opts ...client.CallOption) (*BusinessReply, error)
    // 直接发送tcp请求
    SendAiotReq(ctx context.Context, in *Protocol, opts ...client.CallOption) (*Protocol, error)
    // 发送群组请求
    SendToCluster(ctx context.Context, in *ClusterReq, opts ...client.CallOption) (*BusinessReply, error)
    // 向多个设备同时发起相同参数请求
    SendToNodes(ctx context.Context, in *NodesReq, opts ...client.CallOption) (*BusinessReply, error)
}
type aiotService struct {
@@ -56,8 +62,8 @@
    }
}
func (c *aiotService) GetBusiness(ctx context.Context, in *BusinessReq, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.GetBusiness", in)
func (c *aiotService) SendToNode(ctx context.Context, in *NodeReq, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendToNode", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
@@ -76,17 +82,45 @@
    return out, nil
}
func (c *aiotService) SendToCluster(ctx context.Context, in *ClusterReq, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendToCluster", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
func (c *aiotService) SendToNodes(ctx context.Context, in *NodesReq, opts ...client.CallOption) (*BusinessReply, error) {
    req := c.c.NewRequest(c.name, "AiotService.SendToNodes", in)
    out := new(BusinessReply)
    err := c.c.Call(ctx, req, out, opts...)
    if err != nil {
        return nil, err
    }
    return out, nil
}
// Server API for AiotService service
type AiotServiceHandler interface {
    GetBusiness(context.Context, *BusinessReq, *BusinessReply) error
    // 发送指向单个设备的请求
    SendToNode(context.Context, *NodeReq, *BusinessReply) error
    // 直接发送tcp请求
    SendAiotReq(context.Context, *Protocol, *Protocol) error
    // 发送群组请求
    SendToCluster(context.Context, *ClusterReq, *BusinessReply) error
    // 向多个设备同时发起相同参数请求
    SendToNodes(context.Context, *NodesReq, *BusinessReply) error
}
func RegisterAiotServiceHandler(s server.Server, hdlr AiotServiceHandler, opts ...server.HandlerOption) error {
    type aiotService interface {
        GetBusiness(ctx context.Context, in *BusinessReq, out *BusinessReply) error
        SendToNode(ctx context.Context, in *NodeReq, out *BusinessReply) error
        SendAiotReq(ctx context.Context, in *Protocol, out *Protocol) error
        SendToCluster(ctx context.Context, in *ClusterReq, out *BusinessReply) error
        SendToNodes(ctx context.Context, in *NodesReq, out *BusinessReply) error
    }
    type AiotService struct {
        aiotService
@@ -99,10 +133,18 @@
    AiotServiceHandler
}
func (h *aiotServiceHandler) GetBusiness(ctx context.Context, in *BusinessReq, out *BusinessReply) error {
    return h.AiotServiceHandler.GetBusiness(ctx, in, out)
func (h *aiotServiceHandler) SendToNode(ctx context.Context, in *NodeReq, out *BusinessReply) error {
    return h.AiotServiceHandler.SendToNode(ctx, in, out)
}
func (h *aiotServiceHandler) SendAiotReq(ctx context.Context, in *Protocol, out *Protocol) error {
    return h.AiotServiceHandler.SendAiotReq(ctx, in, out)
}
func (h *aiotServiceHandler) SendToCluster(ctx context.Context, in *ClusterReq, out *BusinessReply) error {
    return h.AiotServiceHandler.SendToCluster(ctx, in, out)
}
func (h *aiotServiceHandler) SendToNodes(ctx context.Context, in *NodesReq, out *BusinessReply) error {
    return h.AiotServiceHandler.SendToNodes(ctx, in, out)
}
aiotProto/aiot/aiot_business.proto
@@ -4,30 +4,74 @@
import "aiot_common.proto";
// 请求类型
enum RequestType{
    Async = 0;
    sync = 1;
    // 同步请求 默认
    sync = 0;
    // 异步请求
    Async = 1;
}
// 请求的body体
message BusinessReq {
message NodeReq {
    // 请求的topic url
    string topic = 1;
    // token
    string authorization = 2;
    // 请求指向的ip
    string ip = 3;
    // 请求的端口 保留字段
    string port = 4;
    RequestType type = 5;
    // 请求的同步/异步类型
    RequestType syncType = 5;
    // 请求业务参数
    bytes req = 6;
}
// 集群请求参数
message ClusterReq{
    // 集群ID
    string ClusterId = 1;
    // token
    string authorization = 2;
    // 请求的同步/异步类型
    RequestType syncType = 3;
    // 请求业务参数
    bytes req = 4;
}
// 设备列表请求参数
message NodesReq{
    // 设备列表ID
    repeated string NodeIds = 1;
    // token
    string authorization = 2;
    // 请求的同步/异步类型
    RequestType syncType = 3;
    // 请求业务参数
    bytes req = 4;
}
// 响应的body体
message BusinessReply {
    // 返回的错误码
    int32 code = 1;
    // 错误信息
    string msg = 2;
    // 是否success
    bool success = 3;
    // 返回结果
    bytes data = 4;
}
// 服务
service AiotService {
    rpc GetBusiness(BusinessReq) returns (BusinessReply){}
    // 发送指向单个设备的请求
    rpc SendToNode(NodeReq) returns (BusinessReply){}
    // 直接发送tcp请求
    rpc SendAiotReq(Protocol) returns (Protocol){}
    // 发送群组请求
    rpc SendToCluster(ClusterReq) returns (BusinessReply){}
    // 向多个设备同时发起相同参数请求
    rpc SendToNodes(NodesReq) returns (BusinessReply) {}
}