feat: implement client-side streaming file upload example and document it in GRPC.md
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v3.21.12
|
||||
// protoc v5.27.2
|
||||
// source: protoapi.proto
|
||||
|
||||
package protoapi
|
||||
@@ -21,6 +21,118 @@ const (
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type FileChunk struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
FileName string `protobuf:"bytes,1,opt,name=FileName,proto3" json:"FileName,omitempty"`
|
||||
Content []byte `protobuf:"bytes,2,opt,name=Content,proto3" json:"Content,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *FileChunk) Reset() {
|
||||
*x = FileChunk{}
|
||||
mi := &file_protoapi_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *FileChunk) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*FileChunk) ProtoMessage() {}
|
||||
|
||||
func (x *FileChunk) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use FileChunk.ProtoReflect.Descriptor instead.
|
||||
func (*FileChunk) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *FileChunk) GetFileName() string {
|
||||
if x != nil {
|
||||
return x.FileName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *FileChunk) GetContent() []byte {
|
||||
if x != nil {
|
||||
return x.Content
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UploadStatus struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Success bool `protobuf:"varint,1,opt,name=Success,proto3" json:"Success,omitempty"`
|
||||
Message string `protobuf:"bytes,2,opt,name=Message,proto3" json:"Message,omitempty"`
|
||||
BytesUploaded int64 `protobuf:"varint,3,opt,name=BytesUploaded,proto3" json:"BytesUploaded,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UploadStatus) Reset() {
|
||||
*x = UploadStatus{}
|
||||
mi := &file_protoapi_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UploadStatus) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UploadStatus) ProtoMessage() {}
|
||||
|
||||
func (x *UploadStatus) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UploadStatus.ProtoReflect.Descriptor instead.
|
||||
func (*UploadStatus) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *UploadStatus) GetSuccess() bool {
|
||||
if x != nil {
|
||||
return x.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *UploadStatus) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UploadStatus) GetBytesUploaded() int64 {
|
||||
if x != nil {
|
||||
return x.BytesUploaded
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type SensingData struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
DeviceId string `protobuf:"bytes,1,opt,name=DeviceId,proto3" json:"DeviceId,omitempty"`
|
||||
@@ -32,7 +144,7 @@ type SensingData struct {
|
||||
|
||||
func (x *SensingData) Reset() {
|
||||
*x = SensingData{}
|
||||
mi := &file_protoapi_proto_msgTypes[0]
|
||||
mi := &file_protoapi_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -44,7 +156,7 @@ func (x *SensingData) String() string {
|
||||
func (*SensingData) ProtoMessage() {}
|
||||
|
||||
func (x *SensingData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[0]
|
||||
mi := &file_protoapi_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -57,7 +169,7 @@ func (x *SensingData) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SensingData.ProtoReflect.Descriptor instead.
|
||||
func (*SensingData) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{0}
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *SensingData) GetDeviceId() string {
|
||||
@@ -91,7 +203,7 @@ type SensingResponse struct {
|
||||
|
||||
func (x *SensingResponse) Reset() {
|
||||
*x = SensingResponse{}
|
||||
mi := &file_protoapi_proto_msgTypes[1]
|
||||
mi := &file_protoapi_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -103,7 +215,7 @@ func (x *SensingResponse) String() string {
|
||||
func (*SensingResponse) ProtoMessage() {}
|
||||
|
||||
func (x *SensingResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[1]
|
||||
mi := &file_protoapi_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -116,7 +228,7 @@ func (x *SensingResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use SensingResponse.ProtoReflect.Descriptor instead.
|
||||
func (*SensingResponse) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{1}
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *SensingResponse) GetSuccess() bool {
|
||||
@@ -142,7 +254,7 @@ type DateTime struct {
|
||||
|
||||
func (x *DateTime) Reset() {
|
||||
*x = DateTime{}
|
||||
mi := &file_protoapi_proto_msgTypes[2]
|
||||
mi := &file_protoapi_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -154,7 +266,7 @@ func (x *DateTime) String() string {
|
||||
func (*DateTime) ProtoMessage() {}
|
||||
|
||||
func (x *DateTime) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[2]
|
||||
mi := &file_protoapi_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -167,7 +279,7 @@ func (x *DateTime) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use DateTime.ProtoReflect.Descriptor instead.
|
||||
func (*DateTime) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{2}
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *DateTime) GetValue() string {
|
||||
@@ -186,7 +298,7 @@ type RequestDateTime struct {
|
||||
|
||||
func (x *RequestDateTime) Reset() {
|
||||
*x = RequestDateTime{}
|
||||
mi := &file_protoapi_proto_msgTypes[3]
|
||||
mi := &file_protoapi_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -198,7 +310,7 @@ func (x *RequestDateTime) String() string {
|
||||
func (*RequestDateTime) ProtoMessage() {}
|
||||
|
||||
func (x *RequestDateTime) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[3]
|
||||
mi := &file_protoapi_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -211,7 +323,7 @@ func (x *RequestDateTime) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use RequestDateTime.ProtoReflect.Descriptor instead.
|
||||
func (*RequestDateTime) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{3}
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *RequestDateTime) GetValue() string {
|
||||
@@ -231,7 +343,7 @@ type RequestPass struct {
|
||||
|
||||
func (x *RequestPass) Reset() {
|
||||
*x = RequestPass{}
|
||||
mi := &file_protoapi_proto_msgTypes[4]
|
||||
mi := &file_protoapi_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -243,7 +355,7 @@ func (x *RequestPass) String() string {
|
||||
func (*RequestPass) ProtoMessage() {}
|
||||
|
||||
func (x *RequestPass) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[4]
|
||||
mi := &file_protoapi_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -256,7 +368,7 @@ func (x *RequestPass) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use RequestPass.ProtoReflect.Descriptor instead.
|
||||
func (*RequestPass) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{4}
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *RequestPass) GetSeed() int64 {
|
||||
@@ -282,7 +394,7 @@ type RandomPass struct {
|
||||
|
||||
func (x *RandomPass) Reset() {
|
||||
*x = RandomPass{}
|
||||
mi := &file_protoapi_proto_msgTypes[5]
|
||||
mi := &file_protoapi_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -294,7 +406,7 @@ func (x *RandomPass) String() string {
|
||||
func (*RandomPass) ProtoMessage() {}
|
||||
|
||||
func (x *RandomPass) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_protoapi_proto_msgTypes[5]
|
||||
mi := &file_protoapi_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -307,7 +419,7 @@ func (x *RandomPass) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use RandomPass.ProtoReflect.Descriptor instead.
|
||||
func (*RandomPass) Descriptor() ([]byte, []int) {
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{5}
|
||||
return file_protoapi_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *RandomPass) GetPassword() string {
|
||||
@@ -321,7 +433,14 @@ var File_protoapi_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_protoapi_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x0eprotoapi.proto\"g\n" +
|
||||
"\x0eprotoapi.proto\"A\n" +
|
||||
"\tFileChunk\x12\x1a\n" +
|
||||
"\bFileName\x18\x01 \x01(\tR\bFileName\x12\x18\n" +
|
||||
"\aContent\x18\x02 \x01(\fR\aContent\"h\n" +
|
||||
"\fUploadStatus\x12\x18\n" +
|
||||
"\aSuccess\x18\x01 \x01(\bR\aSuccess\x12\x18\n" +
|
||||
"\aMessage\x18\x02 \x01(\tR\aMessage\x12$\n" +
|
||||
"\rBytesUploaded\x18\x03 \x01(\x03R\rBytesUploaded\"g\n" +
|
||||
"\vSensingData\x12\x1a\n" +
|
||||
"\bDeviceId\x18\x01 \x01(\tR\bDeviceId\x12 \n" +
|
||||
"\vTemperature\x18\x02 \x01(\x01R\vTemperature\x12\x1a\n" +
|
||||
@@ -338,12 +457,15 @@ const file_protoapi_proto_rawDesc = "" +
|
||||
"\x06Length\x18\b \x01(\x03R\x06Length\"(\n" +
|
||||
"\n" +
|
||||
"RandomPass\x12\x1a\n" +
|
||||
"\bPassword\x18\x01 \x01(\tR\bPassword2\x95\x01\n" +
|
||||
"\bPassword\x18\x01 \x01(\tR\bPassword2\xc0\x01\n" +
|
||||
"\n" +
|
||||
"IoTService\x12&\n" +
|
||||
"\aGetDate\x12\x10.RequestDateTime\x1a\t.DateTime\x123\n" +
|
||||
"\x11UpdateSensingData\x12\f.SensingData\x1a\x10.SensingResponse\x12*\n" +
|
||||
"\rGetRandomPass\x12\f.RequestPass\x1a\v.RandomPassB\x16Z\x14./protoapi/;protoapib\x06proto3"
|
||||
"\rGetRandomPass\x12\f.RequestPass\x1a\v.RandomPass\x12)\n" +
|
||||
"\n" +
|
||||
"UploadFile\x12\n" +
|
||||
".FileChunk\x1a\r.UploadStatus(\x01B\x16Z\x14./protoapi/;protoapib\x06proto3"
|
||||
|
||||
var (
|
||||
file_protoapi_proto_rawDescOnce sync.Once
|
||||
@@ -357,24 +479,28 @@ func file_protoapi_proto_rawDescGZIP() []byte {
|
||||
return file_protoapi_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_protoapi_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_protoapi_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_protoapi_proto_goTypes = []any{
|
||||
(*SensingData)(nil), // 0: SensingData
|
||||
(*SensingResponse)(nil), // 1: SensingResponse
|
||||
(*DateTime)(nil), // 2: DateTime
|
||||
(*RequestDateTime)(nil), // 3: RequestDateTime
|
||||
(*RequestPass)(nil), // 4: RequestPass
|
||||
(*RandomPass)(nil), // 5: RandomPass
|
||||
(*FileChunk)(nil), // 0: FileChunk
|
||||
(*UploadStatus)(nil), // 1: UploadStatus
|
||||
(*SensingData)(nil), // 2: SensingData
|
||||
(*SensingResponse)(nil), // 3: SensingResponse
|
||||
(*DateTime)(nil), // 4: DateTime
|
||||
(*RequestDateTime)(nil), // 5: RequestDateTime
|
||||
(*RequestPass)(nil), // 6: RequestPass
|
||||
(*RandomPass)(nil), // 7: RandomPass
|
||||
}
|
||||
var file_protoapi_proto_depIdxs = []int32{
|
||||
3, // 0: IoTService.GetDate:input_type -> RequestDateTime
|
||||
0, // 1: IoTService.UpdateSensingData:input_type -> SensingData
|
||||
4, // 2: IoTService.GetRandomPass:input_type -> RequestPass
|
||||
2, // 3: IoTService.GetDate:output_type -> DateTime
|
||||
1, // 4: IoTService.UpdateSensingData:output_type -> SensingResponse
|
||||
5, // 5: IoTService.GetRandomPass:output_type -> RandomPass
|
||||
3, // [3:6] is the sub-list for method output_type
|
||||
0, // [0:3] is the sub-list for method input_type
|
||||
5, // 0: IoTService.GetDate:input_type -> RequestDateTime
|
||||
2, // 1: IoTService.UpdateSensingData:input_type -> SensingData
|
||||
6, // 2: IoTService.GetRandomPass:input_type -> RequestPass
|
||||
0, // 3: IoTService.UploadFile:input_type -> FileChunk
|
||||
4, // 4: IoTService.GetDate:output_type -> DateTime
|
||||
3, // 5: IoTService.UpdateSensingData:output_type -> SensingResponse
|
||||
7, // 6: IoTService.GetRandomPass:output_type -> RandomPass
|
||||
1, // 7: IoTService.UploadFile:output_type -> UploadStatus
|
||||
4, // [4:8] is the sub-list for method output_type
|
||||
0, // [0:4] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
@@ -391,7 +517,7 @@ func file_protoapi_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_protoapi_proto_rawDesc), len(file_protoapi_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user