소스 검색

ocr附件识别服务更新

maxiaoshan 1 년 전
부모
커밋
a7b25c68cb

+ 1 - 1
download_file/src/config.json

@@ -15,7 +15,7 @@
     "to": "maxiaoshan@topnet.net.cn",
     "api": "http://172.17.145.179:19281/_send/_mail"
   },
-  "ocrserveraddr": "192.168.3.12:10021",
+  "ocrserveraddr": "192.168.3.240:9090",
   "bidding": {
     "mongodb": "192.168.3.166:27082",
     "db": "qfw",

+ 459 - 0
download_file/src/fileproto/filevector.pb.go

@@ -0,0 +1,459 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.28.0
+// 	protoc        v3.19.4
+// source: fileproto/filevector.proto
+
+//附件传输
+
+package fileproto
+
+import (
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
+)
+
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type FileRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Message []*Request `protobuf:"bytes,1,rep,name=message,proto3" json:"message,omitempty"` //文件名称
+	Other   string     `protobuf:"bytes,2,opt,name=other,proto3" json:"other,omitempty"`     //信息id
+	Topic   string     `protobuf:"bytes,3,opt,name=topic,proto3" json:"topic,omitempty"`
+}
+
+func (x *FileRequest) Reset() {
+	*x = FileRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_fileproto_filevector_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *FileRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*FileRequest) ProtoMessage() {}
+
+func (x *FileRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_fileproto_filevector_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use FileRequest.ProtoReflect.Descriptor instead.
+func (*FileRequest) Descriptor() ([]byte, []int) {
+	return file_fileproto_filevector_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *FileRequest) GetMessage() []*Request {
+	if x != nil {
+		return x.Message
+	}
+	return nil
+}
+
+func (x *FileRequest) GetOther() string {
+	if x != nil {
+		return x.Other
+	}
+	return ""
+}
+
+func (x *FileRequest) GetTopic() string {
+	if x != nil {
+		return x.Topic
+	}
+	return ""
+}
+
+type Request struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	FileName    string `protobuf:"bytes,1,opt,name=fileName,proto3" json:"fileName,omitempty"`        //文件名称
+	FileUrl     string `protobuf:"bytes,2,opt,name=fileUrl,proto3" json:"fileUrl,omitempty"`          //下载的url
+	FileBytes   []byte `protobuf:"bytes,3,opt,name=fileBytes,proto3" json:"fileBytes,omitempty"`      //文件字节流
+	FileType    string `protobuf:"bytes,4,opt,name=fileType,proto3" json:"fileType,omitempty"`        //文件类型 pdf ,xls ,doc
+	ReturnType  int32  `protobuf:"varint,5,opt,name=returnType,proto3" json:"returnType,omitempty"`   //文件类型 {0:url,1:content,2:url+content} 默认0
+	ExtractType int32  `protobuf:"varint,6,opt,name=extractType,proto3" json:"extractType,omitempty"` //解析文件类型{0:oss,1:fileBytes,2:url} 默认0
+}
+
+func (x *Request) Reset() {
+	*x = Request{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_fileproto_filevector_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Request) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Request) ProtoMessage() {}
+
+func (x *Request) ProtoReflect() protoreflect.Message {
+	mi := &file_fileproto_filevector_proto_msgTypes[1]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Request.ProtoReflect.Descriptor instead.
+func (*Request) Descriptor() ([]byte, []int) {
+	return file_fileproto_filevector_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *Request) GetFileName() string {
+	if x != nil {
+		return x.FileName
+	}
+	return ""
+}
+
+func (x *Request) GetFileUrl() string {
+	if x != nil {
+		return x.FileUrl
+	}
+	return ""
+}
+
+func (x *Request) GetFileBytes() []byte {
+	if x != nil {
+		return x.FileBytes
+	}
+	return nil
+}
+
+func (x *Request) GetFileType() string {
+	if x != nil {
+		return x.FileType
+	}
+	return ""
+}
+
+func (x *Request) GetReturnType() int32 {
+	if x != nil {
+		return x.ReturnType
+	}
+	return 0
+}
+
+func (x *Request) GetExtractType() int32 {
+	if x != nil {
+		return x.ExtractType
+	}
+	return 0
+}
+
+type FileResponse struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Result []*Result `protobuf:"bytes,1,rep,name=result,proto3" json:"result,omitempty"` //返回结果
+	Other  string    `protobuf:"bytes,2,opt,name=other,proto3" json:"other,omitempty"`   //信息id
+}
+
+func (x *FileResponse) Reset() {
+	*x = FileResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_fileproto_filevector_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *FileResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*FileResponse) ProtoMessage() {}
+
+func (x *FileResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_fileproto_filevector_proto_msgTypes[2]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use FileResponse.ProtoReflect.Descriptor instead.
+func (*FileResponse) Descriptor() ([]byte, []int) {
+	return file_fileproto_filevector_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *FileResponse) GetResult() []*Result {
+	if x != nil {
+		return x.Result
+	}
+	return nil
+}
+
+func (x *FileResponse) GetOther() string {
+	if x != nil {
+		return x.Other
+	}
+	return ""
+}
+
+type Result struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	FileName    string `protobuf:"bytes,1,opt,name=fileName,proto3" json:"fileName,omitempty"`       //文件名称
+	TextContent string `protobuf:"bytes,2,opt,name=textContent,proto3" json:"textContent,omitempty"` //文本内容
+	TextUrl     string `protobuf:"bytes,3,opt,name=textUrl,proto3" json:"textUrl,omitempty"`         //文本URL
+	FilePath    string `protobuf:"bytes,4,opt,name=filePath,proto3" json:"filePath,omitempty"`       //文件路径
+	ErrorState  string `protobuf:"bytes,5,opt,name=errorState,proto3" json:"errorState,omitempty"`   //错误状态{0:文件下载失败,1:文件解析失败}
+}
+
+func (x *Result) Reset() {
+	*x = Result{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_fileproto_filevector_proto_msgTypes[3]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Result) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Result) ProtoMessage() {}
+
+func (x *Result) ProtoReflect() protoreflect.Message {
+	mi := &file_fileproto_filevector_proto_msgTypes[3]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Result.ProtoReflect.Descriptor instead.
+func (*Result) Descriptor() ([]byte, []int) {
+	return file_fileproto_filevector_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *Result) GetFileName() string {
+	if x != nil {
+		return x.FileName
+	}
+	return ""
+}
+
+func (x *Result) GetTextContent() string {
+	if x != nil {
+		return x.TextContent
+	}
+	return ""
+}
+
+func (x *Result) GetTextUrl() string {
+	if x != nil {
+		return x.TextUrl
+	}
+	return ""
+}
+
+func (x *Result) GetFilePath() string {
+	if x != nil {
+		return x.FilePath
+	}
+	return ""
+}
+
+func (x *Result) GetErrorState() string {
+	if x != nil {
+		return x.ErrorState
+	}
+	return ""
+}
+
+var File_fileproto_filevector_proto protoreflect.FileDescriptor
+
+var file_fileproto_filevector_proto_rawDesc = []byte{
+	0x0a, 0x1a, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x66, 0x69, 0x6c, 0x65,
+	0x76, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x22, 0x63, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
+	0x73, 0x74, 0x12, 0x28, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20,
+	0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x71, 0x75,
+	0x65, 0x73, 0x74, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05,
+	0x6f, 0x74, 0x68, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x74, 0x68,
+	0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x22, 0xbb, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71,
+	0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65,
+	0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65,
+	0x12, 0x18, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x65, 0x55, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x69,
+	0x6c, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x66,
+	0x69, 0x6c, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65,
+	0x54, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65,
+	0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x54, 0x79,
+	0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+	0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x54,
+	0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x65, 0x78, 0x74, 0x72, 0x61,
+	0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x4b, 0x0a, 0x0c, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65,
+	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74,
+	0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52,
+	0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a,
+	0x05, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x74,
+	0x68, 0x65, 0x72, 0x22, 0x9c, 0x01, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1a,
+	0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x74, 0x65,
+	0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x0b, 0x74, 0x65, 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07,
+	0x74, 0x65, 0x78, 0x74, 0x55, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74,
+	0x65, 0x78, 0x74, 0x55, 0x72, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x50, 0x61,
+	0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x50, 0x61,
+	0x74, 0x68, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x74, 0x61, 0x74, 0x65,
+	0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x53, 0x74, 0x61,
+	0x74, 0x65, 0x32, 0x45, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x45, 0x78, 0x74, 0x72, 0x61, 0x63,
+	0x74, 0x12, 0x36, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x45, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74,
+	0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71,
+	0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x69, 0x6c,
+	0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x08, 0x5a, 0x06, 0x2f, 0x70, 0x72,
+	0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_fileproto_filevector_proto_rawDescOnce sync.Once
+	file_fileproto_filevector_proto_rawDescData = file_fileproto_filevector_proto_rawDesc
+)
+
+func file_fileproto_filevector_proto_rawDescGZIP() []byte {
+	file_fileproto_filevector_proto_rawDescOnce.Do(func() {
+		file_fileproto_filevector_proto_rawDescData = protoimpl.X.CompressGZIP(file_fileproto_filevector_proto_rawDescData)
+	})
+	return file_fileproto_filevector_proto_rawDescData
+}
+
+var file_fileproto_filevector_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_fileproto_filevector_proto_goTypes = []interface{}{
+	(*FileRequest)(nil),  // 0: proto.FileRequest
+	(*Request)(nil),      // 1: proto.Request
+	(*FileResponse)(nil), // 2: proto.FileResponse
+	(*Result)(nil),       // 3: proto.Result
+}
+var file_fileproto_filevector_proto_depIdxs = []int32{
+	1, // 0: proto.FileRequest.message:type_name -> proto.Request
+	3, // 1: proto.FileResponse.result:type_name -> proto.Result
+	0, // 2: proto.FileExtract.FileExtract:input_type -> proto.FileRequest
+	2, // 3: proto.FileExtract.FileExtract:output_type -> proto.FileResponse
+	3, // [3:4] is the sub-list for method output_type
+	2, // [2:3] is the sub-list for method input_type
+	2, // [2:2] is the sub-list for extension type_name
+	2, // [2:2] is the sub-list for extension extendee
+	0, // [0:2] is the sub-list for field type_name
+}
+
+func init() { file_fileproto_filevector_proto_init() }
+func file_fileproto_filevector_proto_init() {
+	if File_fileproto_filevector_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_fileproto_filevector_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*FileRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_fileproto_filevector_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Request); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_fileproto_filevector_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*FileResponse); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_fileproto_filevector_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Result); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_fileproto_filevector_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   4,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_fileproto_filevector_proto_goTypes,
+		DependencyIndexes: file_fileproto_filevector_proto_depIdxs,
+		MessageInfos:      file_fileproto_filevector_proto_msgTypes,
+	}.Build()
+	File_fileproto_filevector_proto = out.File
+	file_fileproto_filevector_proto_rawDesc = nil
+	file_fileproto_filevector_proto_goTypes = nil
+	file_fileproto_filevector_proto_depIdxs = nil
+}

+ 0 - 0
download_file/src/proto/filetext.proto → download_file/src/fileproto/filevector.proto


+ 38 - 42
download_file/src/filetext_grpc.go

@@ -2,68 +2,64 @@ package main
 
 import (
 	"context"
+	"fileproto"
+	"fmt"
+	"github.com/golang/protobuf/proto"
 	"google.golang.org/grpc"
-	"proto"
 	qu "qfw/util"
+	server "server"
+	"time"
+	. "util"
 )
 
-var FileTextClient proto.FileExtractClient
+var FileTextClient server.CallerClient
 
-//直接调用接口地址
-//func InitFileTextGrpcClient() {
-//	defer qu.Catch()
-//	qu.Debug("address:", qu.ObjToString(Config["ocrserveraddr"])) //192.168.3.13:22101
-//	conn, err := grpc.Dial(qu.ObjToString(Config["ocrserveraddr"]), grpc.WithTransportCredentials(insecure.NewCredentials()))
-//	if err != nil {
-//		qu.Debug("Init Connect Error: ", err)
-//	}
-//	FileTextClient = proto.NewFileExtractClient(conn)
-//}
-
-func GetFileText_back(fileName, fileUrl, fileType string, fileBytes []byte) (*proto.FileResponse, error) {
+//初始化客户端
+func InitFileTextGrpcClient() {
 	defer qu.Catch()
-	req := &proto.Request{
-		FileName:    fileName,
-		FileUrl:     fileUrl,
-		FileType:    fileType,
-		FileBytes:   fileBytes,
-		ExtractType: 1,
-		ReturnType:  0, //正式环境改为0
-	}
-	fileReq := &proto.FileRequest{
-		Message: []*proto.Request{
-			req,
-		},
-	}
-	resp, err := FileTextClient.FileExtract(context.Background(), fileReq)
+	// 连接服务器
+	t1 := time.Now()
+	conn, err := grpc.Dial(OcrServerAddr, grpc.WithInsecure())
 	if err != nil {
-		return nil, err
+		fmt.Printf("连接服务端失败: %s", err)
+		return
+	} else {
+		fmt.Println("连接服务端OK")
 	}
-	qu.Debug(resp.Result)
-	return resp, nil
+	fmt.Println("连接GRPC耗时:", time.Since(t1))
+	// 新建一个客户端
+	FileTextClient = server.NewCallerClient(conn)
 }
 
-func GetFileText(conn *grpc.ClientConn, fileName, fileUrl, fileType string, fileBytes []byte) *proto.FileResponse {
+func GetFileText(fileName, fileUrl, fileType string, fileBytes []byte) *fileproto.FileResponse {
 	defer qu.Catch()
-	FileTextClient = proto.NewFileExtractClient(conn)
-	defer conn.Close()
-	req := &proto.Request{
+	params := &fileproto.Request{
 		FileName:    fileName,
 		FileUrl:     fileUrl,
 		FileType:    fileType,
 		FileBytes:   fileBytes,
-		ExtractType: 1,
 		ReturnType:  0, //正式环境改为0
+		ExtractType: 1,
 	}
-	fileReq := &proto.FileRequest{
-		Message: []*proto.Request{
-			req,
+	aa := &fileproto.FileRequest{
+		Message: []*fileproto.Request{
+			params,
 		},
 	}
-	resp, err := FileTextClient.FileExtract(context.Background(), fileReq)
+	bs, _ := proto.Marshal(aa)
+	resp, err := FileTextClient.Call(context.Background(), &server.Request{
+		Topic:   "file2txt",
+		Timeout: 300,
+		Data:    bs,
+	})
 	if err != nil {
+		fmt.Println("调用服务端代码失败: ", err.Error())
 		return nil
 	}
-	//qu.Debug(resp.Result)
-	return resp
+	respData := new(fileproto.FileResponse)
+	err = proto.Unmarshal(resp.GetData(), respData)
+	if err != nil {
+		fmt.Println("结果解析失败...")
+	}
+	return respData
 }

+ 1 - 1
download_file/src/main.go

@@ -52,7 +52,7 @@ func init() {
 	)
 	//初始化grpc
 	OcrServerAddr = qu.ObjToString(Config["ocrserveraddr"])
-	//InitFileTextGrpcClient()
+	InitFileTextGrpcClient()
 	go checkMapJob()
 }
 

+ 47 - 0
download_file/src/mainT.go

@@ -0,0 +1,47 @@
+package main
+
+import (
+	"bytes"
+	"fmt"
+	"io"
+	qu "qfw/util"
+	sp "spiderutil"
+)
+
+//调用附件解析ocr测试
+func mainT1() {
+	attachText := map[string]interface{}{}
+	url := "https://e-bidding.zzcycn.com/bidprocurement/datacenter-cebpubserver/cebpubserver/dataCeboubServerCommonController/openFileById?fileType=2&id=c66b56202bfe4420abc0208b7c3bb9f3"
+	contentType, ret := Download(url) //下载
+	fmt.Println(contentType)
+	fileType := "pdf" //从url或者text提取的附件类型
+	fileName := "公告.pdf"
+	fid := sp.GetHashKey(ret) + sp.TypeByExt(fileName)
+	fmt.Println(fid)
+	bs := bytes.NewReader(ret)
+	Ok, _ := sp.OssPutObject(fid, io.MultiReader(bs)) //附件上传
+	if Ok {                                           //上传成功,解析附件
+		resp := GetFileText(fileName, fid, fileType, ret)
+		fmt.Println(resp)
+		if resp != nil {
+			tmap := map[string]interface{}{}
+			for i, r := range resp.Result {
+				rmap := map[string]interface{}{
+					"file_name":  r.FileName,
+					"attach_url": r.TextUrl,
+					"state":      r.ErrorState,
+				}
+				tmap[fmt.Sprint(i)] = rmap
+			}
+			if len(tmap) > 0 {
+				attachText[fmt.Sprint(1)] = tmap
+			}
+		}
+	}
+	qu.Debug(attachText)
+}
+
+//流程测试
+func mainT() {
+	GetDataAndDownload("6556f82c27f8b3af542c05f1", "6556f82c27f8b3af542c05f2")
+}

+ 132 - 0
download_file/src/server/message.go

@@ -0,0 +1,132 @@
+package a2s
+
+import (
+	"fmt"
+	"log"
+	"math/rand"
+	"strings"
+	"sync"
+	"time"
+
+	"github.com/golang/protobuf/proto"
+	"github.com/nats-io/nats.go"
+)
+
+const (
+	ID_LENGTH = 32
+)
+
+type (
+	Bytes []byte
+	//观察结果
+	WatchResponse struct {
+		lock  *sync.RWMutex
+		cache map[string]chan Bytes
+	}
+	//坚听返回队列
+	WatchNatsQueue struct {
+		lock  *sync.RWMutex
+		cache map[string]bool
+	}
+)
+
+var (
+	noice = "abcdefghijklmnopqrstuvwxyz0123456789"
+	nc    *nats.Conn
+	w     = &WatchResponse{new(sync.RWMutex), make(map[string]chan Bytes)}
+	wnq   = &WatchNatsQueue{new(sync.RWMutex), make(map[string]bool)}
+)
+
+// id
+func id() string {
+	sb := new(strings.Builder)
+	for i := 0; i < ID_LENGTH; i++ {
+		sb.WriteByte(noice[rand.Intn(36)])
+	}
+	return sb.String()
+}
+
+// Add 方法调用时,添加观察
+func (wr *WatchResponse) Add(msgId string, ch chan Bytes) {
+	wr.lock.Lock()
+	defer wr.lock.Unlock()
+	wr.cache[msgId] = ch
+}
+
+// Del 超时/成功时,删除观察
+func (wr *WatchResponse) Del(msgId string) {
+	wr.lock.Lock()
+	defer wr.lock.Unlock()
+	if v, ok := wr.cache[msgId]; ok {
+		close(v)
+		delete(wr.cache, msgId)
+	}
+}
+
+// Put 写入channel,select观察会有响应
+func (wr *WatchResponse) Put(msgId string, data Bytes) {
+	wr.lock.Lock()
+	defer wr.lock.Unlock()
+	if v, ok := wr.cache[msgId]; ok {
+		v <- data
+	}
+}
+
+// Watch
+func (wnq *WatchNatsQueue) Watch(topic string) {
+	wnq.lock.Lock()
+	defer wnq.lock.Unlock()
+	if _, ok := wnq.cache[topic]; ok {
+		return
+	} else {
+		wnq.cache[topic] = true
+		rawTopic := fmt.Sprintf("%s_resp", topic)
+		nc.QueueSubscribe(rawTopic, rawTopic, func(msg *nats.Msg) {
+			obj := new(NatsResponse)
+			err := proto.Unmarshal(msg.Data, obj)
+			if err == nil {
+				w.Put(obj.GetMsgId(), obj.GetData())
+			}
+		})
+	}
+}
+
+// ConnectNats
+func ConnectNats(addr string) error {
+	var err error
+	natsAddr := fmt.Sprintf("nats://%s", addr)
+	log.Println(natsAddr)
+	nc, err = nats.Connect(natsAddr)
+	return err
+}
+
+// SendMessage2Nats
+func SendMessage2Nats(topic string,
+	timeout int64,
+	data []byte) (string, <-chan Bytes, error) {
+	rawTopic := fmt.Sprintf("%s_req", topic)
+	//
+	msgId := id()
+	rawData := &NatsRequest{
+		MsgId:     msgId,
+		Timestamp: time.Now().Unix(),
+		Timeout:   timeout,
+		Data:      data,
+	}
+	//
+	bs, err := proto.Marshal(rawData)
+	if err != nil {
+		return "", nil, err
+	}
+	//发布消息到指定队列
+	err = nc.Publish(rawTopic, bs)
+	if err != nil {
+		return "", nil, err
+	}
+	ch := make(chan Bytes, 1)
+	//
+	wnq.Watch(topic)
+	//
+	w.Add(msgId, ch)
+	return msgId, ch, nil
+}

+ 89 - 0
download_file/src/server/server.go

@@ -0,0 +1,89 @@
+package a2s
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"log"
+	"net"
+	"sync/atomic"
+	"time"
+
+	"github.com/cespare/xxhash/v2"
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/reflection"
+)
+
+type (
+	//GRPC 服务端
+	Server struct{}
+)
+
+var (
+	reqAmout = make([]int32, 9999, 9999)
+)
+
+// Call 远程调用
+func (s *Server) Call(ctx context.Context,
+	in *Request) (*Response, error) {
+	topicIndex := int(xxhash.Sum64([]byte(in.GetTopic()))) % 9999
+	if topicIndex < 0 {
+		topicIndex *= -1
+	}
+	atomic.AddInt32(&(reqAmout[topicIndex]), 1)
+	defer func() {
+		fmt.Print(".")
+		atomic.AddInt32(&(reqAmout[topicIndex]), -1)
+	}()
+	fmt.Print(">")
+	msgId, ch, err := SendMessage2Nats(in.GetTopic(), in.GetTimeout(), in.GetData())
+	if err != nil {
+		return &Response{}, err
+	}
+
+	//等候
+	select {
+	case <-ctx.Done():
+		w.Del(msgId)
+		return &Response{Code: 203, Msg: "客户端主动关闭连接"}, errors.New("client close the connection")
+	case <-time.After(time.Duration(in.Timeout) * time.Second):
+		//超时
+		w.Del(msgId)
+		return &Response{Code: 500, Msg: "远程方法调用超时"}, errors.New("call remote method timeout")
+	case ret := <-ch:
+		w.Del(msgId)
+		return &Response{Code: 200, Msg: "ok", Data: ret}, nil
+	}
+	return &Response{Code: 503, Msg: "未知错误"}, errors.New("unknow error")
+}
+
+// ViewState 查看状态
+func (s *Server) ViewState(ctx context.Context, req *StateReq) (*StateResp, error) {
+	topicIndex := int(xxhash.Sum64([]byte(req.GetTopic()))) % 9999
+	if topicIndex < 0 {
+		topicIndex *= -1
+	}
+	return &StateResp{CurrentRequest: reqAmout[topicIndex]}, nil
+}
+
+// startServer 开启RPC服务
+func StartServer(listen string) {
+	// 监听本地端口
+	lis, err := net.Listen("tcp", listen)
+	if err != nil {
+		log.Printf("监听端口失败: %s\n", err)
+		return
+	} else {
+		log.Printf("监听端口:%s\n", listen)
+	}
+	// 创建gRPC服务器
+	s := grpc.NewServer()
+	// 注册服务
+	RegisterCallerServer(s, new(Server))
+	reflection.Register(s)
+	err = s.Serve(lis)
+	if err != nil {
+		log.Printf("开启服务失败: %s\n", err)
+		return
+	}
+}

+ 668 - 0
download_file/src/server/service.pb.go

@@ -0,0 +1,668 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.31.0
+// 	protoc        v4.24.3
+// source: service.proto
+
+package a2s
+
+import (
+	context "context"
+	grpc "google.golang.org/grpc"
+	codes "google.golang.org/grpc/codes"
+	status "google.golang.org/grpc/status"
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
+)
+
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+// 请求
+type Request struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Topic   string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`      //主题
+	Timeout int64  `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` //超时设定
+	Data    []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`        //数据序列化
+}
+
+func (x *Request) Reset() {
+	*x = Request{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_service_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Request) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Request) ProtoMessage() {}
+
+func (x *Request) ProtoReflect() protoreflect.Message {
+	mi := &file_service_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Request.ProtoReflect.Descriptor instead.
+func (*Request) Descriptor() ([]byte, []int) {
+	return file_service_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *Request) GetTopic() string {
+	if x != nil {
+		return x.Topic
+	}
+	return ""
+}
+
+func (x *Request) GetTimeout() int64 {
+	if x != nil {
+		return x.Timeout
+	}
+	return 0
+}
+
+func (x *Request) GetData() []byte {
+	if x != nil {
+		return x.Data
+	}
+	return nil
+}
+
+// 回应
+type Response struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Code int32  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` //返回码
+	Msg  string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`    //
+	Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`  //结构数据
+}
+
+func (x *Response) Reset() {
+	*x = Response{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_service_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *Response) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*Response) ProtoMessage() {}
+
+func (x *Response) ProtoReflect() protoreflect.Message {
+	mi := &file_service_proto_msgTypes[1]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use Response.ProtoReflect.Descriptor instead.
+func (*Response) Descriptor() ([]byte, []int) {
+	return file_service_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *Response) GetCode() int32 {
+	if x != nil {
+		return x.Code
+	}
+	return 0
+}
+
+func (x *Response) GetMsg() string {
+	if x != nil {
+		return x.Msg
+	}
+	return ""
+}
+
+func (x *Response) GetData() []byte {
+	if x != nil {
+		return x.Data
+	}
+	return nil
+}
+
+// 空消息体
+type StateReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"`
+}
+
+func (x *StateReq) Reset() {
+	*x = StateReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_service_proto_msgTypes[2]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *StateReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*StateReq) ProtoMessage() {}
+
+func (x *StateReq) ProtoReflect() protoreflect.Message {
+	mi := &file_service_proto_msgTypes[2]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use StateReq.ProtoReflect.Descriptor instead.
+func (*StateReq) Descriptor() ([]byte, []int) {
+	return file_service_proto_rawDescGZIP(), []int{2}
+}
+
+func (x *StateReq) GetTopic() string {
+	if x != nil {
+		return x.Topic
+	}
+	return ""
+}
+
+// 状态消息体
+type StateResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	CurrentRequest int32 `protobuf:"varint,1,opt,name=currentRequest,proto3" json:"currentRequest,omitempty"` //当前处理的请求数
+}
+
+func (x *StateResp) Reset() {
+	*x = StateResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_service_proto_msgTypes[3]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *StateResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*StateResp) ProtoMessage() {}
+
+func (x *StateResp) ProtoReflect() protoreflect.Message {
+	mi := &file_service_proto_msgTypes[3]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use StateResp.ProtoReflect.Descriptor instead.
+func (*StateResp) Descriptor() ([]byte, []int) {
+	return file_service_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *StateResp) GetCurrentRequest() int32 {
+	if x != nil {
+		return x.CurrentRequest
+	}
+	return 0
+}
+
+// 发送给nats的消息体
+type NatsRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	MsgId     string `protobuf:"bytes,1,opt,name=msgId,proto3" json:"msgId,omitempty"`
+	Timestamp int64  `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
+	Timeout   int64  `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"`
+	Data      []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
+}
+
+func (x *NatsRequest) Reset() {
+	*x = NatsRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_service_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *NatsRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*NatsRequest) ProtoMessage() {}
+
+func (x *NatsRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_service_proto_msgTypes[4]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use NatsRequest.ProtoReflect.Descriptor instead.
+func (*NatsRequest) Descriptor() ([]byte, []int) {
+	return file_service_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *NatsRequest) GetMsgId() string {
+	if x != nil {
+		return x.MsgId
+	}
+	return ""
+}
+
+func (x *NatsRequest) GetTimestamp() int64 {
+	if x != nil {
+		return x.Timestamp
+	}
+	return 0
+}
+
+func (x *NatsRequest) GetTimeout() int64 {
+	if x != nil {
+		return x.Timeout
+	}
+	return 0
+}
+
+func (x *NatsRequest) GetData() []byte {
+	if x != nil {
+		return x.Data
+	}
+	return nil
+}
+
+// 回应给nats的消息体
+type NatsResponse struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	MsgId string `protobuf:"bytes,1,opt,name=msgId,proto3" json:"msgId,omitempty"`
+	Data  []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
+}
+
+func (x *NatsResponse) Reset() {
+	*x = NatsResponse{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_service_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *NatsResponse) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*NatsResponse) ProtoMessage() {}
+
+func (x *NatsResponse) ProtoReflect() protoreflect.Message {
+	mi := &file_service_proto_msgTypes[5]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use NatsResponse.ProtoReflect.Descriptor instead.
+func (*NatsResponse) Descriptor() ([]byte, []int) {
+	return file_service_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *NatsResponse) GetMsgId() string {
+	if x != nil {
+		return x.MsgId
+	}
+	return ""
+}
+
+func (x *NatsResponse) GetData() []byte {
+	if x != nil {
+		return x.Data
+	}
+	return nil
+}
+
+var File_service_proto protoreflect.FileDescriptor
+
+var file_service_proto_rawDesc = []byte{
+	0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
+	0x04, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x4d, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+	0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75,
+	0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74,
+	0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04,
+	0x64, 0x61, 0x74, 0x61, 0x22, 0x44, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
+	0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04,
+	0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03,
+	0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x20, 0x0a, 0x08, 0x53, 0x74,
+	0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18,
+	0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x22, 0x33, 0x0a, 0x09,
+	0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x26, 0x0a, 0x0e, 0x63, 0x75, 0x72,
+	0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x05, 0x52, 0x0e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
+	0x74, 0x22, 0x6f, 0x0a, 0x0b, 0x4e, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+	0x12, 0x14, 0x0a, 0x05, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
+	0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73,
+	0x74, 0x61, 0x6d, 0x70, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18,
+	0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x12,
+	0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61,
+	0x74, 0x61, 0x22, 0x38, 0x0a, 0x0c, 0x4e, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+	0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x05, 0x6d, 0x73, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
+	0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x61, 0x0a, 0x06,
+	0x43, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x0d,
+	0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e,
+	0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
+	0x2e, 0x0a, 0x09, 0x56, 0x69, 0x65, 0x77, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x0e, 0x2e, 0x6d,
+	0x61, 0x69, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x6d,
+	0x61, 0x69, 0x6e, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x42,
+	0x07, 0x5a, 0x05, 0x2e, 0x3b, 0x61, 0x32, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_service_proto_rawDescOnce sync.Once
+	file_service_proto_rawDescData = file_service_proto_rawDesc
+)
+
+func file_service_proto_rawDescGZIP() []byte {
+	file_service_proto_rawDescOnce.Do(func() {
+		file_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_proto_rawDescData)
+	})
+	return file_service_proto_rawDescData
+}
+
+var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
+var file_service_proto_goTypes = []interface{}{
+	(*Request)(nil),      // 0: main.Request
+	(*Response)(nil),     // 1: main.Response
+	(*StateReq)(nil),     // 2: main.StateReq
+	(*StateResp)(nil),    // 3: main.StateResp
+	(*NatsRequest)(nil),  // 4: main.NatsRequest
+	(*NatsResponse)(nil), // 5: main.NatsResponse
+}
+var file_service_proto_depIdxs = []int32{
+	0, // 0: main.Caller.Call:input_type -> main.Request
+	2, // 1: main.Caller.ViewState:input_type -> main.StateReq
+	1, // 2: main.Caller.Call:output_type -> main.Response
+	3, // 3: main.Caller.ViewState:output_type -> main.StateResp
+	2, // [2:4] is the sub-list for method output_type
+	0, // [0:2] 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
+}
+
+func init() { file_service_proto_init() }
+func file_service_proto_init() {
+	if File_service_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Request); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*Response); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*StateReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*StateResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*NatsRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*NatsResponse); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_service_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   6,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_service_proto_goTypes,
+		DependencyIndexes: file_service_proto_depIdxs,
+		MessageInfos:      file_service_proto_msgTypes,
+	}.Build()
+	File_service_proto = out.File
+	file_service_proto_rawDesc = nil
+	file_service_proto_goTypes = nil
+	file_service_proto_depIdxs = nil
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConnInterface
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion6
+
+// CallerClient is the client API for Caller service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
+type CallerClient interface {
+	// 远程调用
+	Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
+	// 状态查看
+	ViewState(ctx context.Context, in *StateReq, opts ...grpc.CallOption) (*StateResp, error)
+}
+
+type callerClient struct {
+	cc grpc.ClientConnInterface
+}
+
+func NewCallerClient(cc grpc.ClientConnInterface) CallerClient {
+	return &callerClient{cc}
+}
+
+func (c *callerClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
+	out := new(Response)
+	err := c.cc.Invoke(ctx, "/main.Caller/Call", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *callerClient) ViewState(ctx context.Context, in *StateReq, opts ...grpc.CallOption) (*StateResp, error) {
+	out := new(StateResp)
+	err := c.cc.Invoke(ctx, "/main.Caller/ViewState", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+// CallerServer is the server API for Caller service.
+type CallerServer interface {
+	// 远程调用
+	Call(context.Context, *Request) (*Response, error)
+	// 状态查看
+	ViewState(context.Context, *StateReq) (*StateResp, error)
+}
+
+// UnimplementedCallerServer can be embedded to have forward compatible implementations.
+type UnimplementedCallerServer struct {
+}
+
+func (*UnimplementedCallerServer) Call(context.Context, *Request) (*Response, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method Call not implemented")
+}
+func (*UnimplementedCallerServer) ViewState(context.Context, *StateReq) (*StateResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ViewState not implemented")
+}
+
+func RegisterCallerServer(s *grpc.Server, srv CallerServer) {
+	s.RegisterService(&_Caller_serviceDesc, srv)
+}
+
+func _Caller_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(Request)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(CallerServer).Call(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/main.Caller/Call",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(CallerServer).Call(ctx, req.(*Request))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _Caller_ViewState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(StateReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(CallerServer).ViewState(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/main.Caller/ViewState",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(CallerServer).ViewState(ctx, req.(*StateReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+var _Caller_serviceDesc = grpc.ServiceDesc{
+	ServiceName: "main.Caller",
+	HandlerType: (*CallerServer)(nil),
+	Methods: []grpc.MethodDesc{
+		{
+			MethodName: "Call",
+			Handler:    _Caller_Call_Handler,
+		},
+		{
+			MethodName: "ViewState",
+			Handler:    _Caller_ViewState_Handler,
+		},
+	},
+	Streams:  []grpc.StreamDesc{},
+	Metadata: "service.proto",
+}

+ 43 - 0
download_file/src/server/service.proto

@@ -0,0 +1,43 @@
+syntax = "proto3";
+package main;
+option go_package = ".;a2s";
+
+service Caller {
+  //远程调用
+  rpc Call (Request) returns (Response) {}
+  //状态查看
+  rpc ViewState(StateReq)returns(StateResp){}
+}
+//请求
+message Request {
+  string topic = 1;//主题
+  int64 timeout = 2;//超时设定
+  bytes data =3;//数据序列化
+}
+//回应
+message Response {
+  int32 code =1;//返回码
+  string msg = 2;//
+  bytes data =3;//结构数据
+}
+//空消息体
+message StateReq{
+	string topic =1;
+}
+//状态消息体
+message StateResp{
+  int32 currentRequest =1 ; //当前处理的请求数
+}
+
+//发送给nats的消息体
+message NatsRequest{
+	string msgId =1;
+	int64 timestamp = 2;
+	int64  timeout =3;
+	bytes data=4;
+}
+//回应给nats的消息体
+message NatsResponse{
+	string msgId =1;
+	bytes data=4;
+}

+ 0 - 261
download_file/src/serviced/proto/heartbeat.pb.go

@@ -1,261 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: heartbeat.proto
-
-//声明 包名
-
-package proto
-
-import (
-	context "context"
-	fmt "fmt"
-	proto "github.com/golang/protobuf/proto"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-	math "math"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
-//stream请求结构
-type StreamReqData struct {
-	ServiceName          string   `protobuf:"bytes,1,opt,name=serviceName,proto3" json:"serviceName,omitempty"`
-	ServiceIp            string   `protobuf:"bytes,2,opt,name=serviceIp,proto3" json:"serviceIp,omitempty"`
-	ServicePort          int32    `protobuf:"varint,3,opt,name=servicePort,proto3" json:"servicePort,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *StreamReqData) Reset()         { *m = StreamReqData{} }
-func (m *StreamReqData) String() string { return proto.CompactTextString(m) }
-func (*StreamReqData) ProtoMessage()    {}
-func (*StreamReqData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_3c667767fb9826a9, []int{0}
-}
-
-func (m *StreamReqData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_StreamReqData.Unmarshal(m, b)
-}
-func (m *StreamReqData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_StreamReqData.Marshal(b, m, deterministic)
-}
-func (m *StreamReqData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_StreamReqData.Merge(m, src)
-}
-func (m *StreamReqData) XXX_Size() int {
-	return xxx_messageInfo_StreamReqData.Size(m)
-}
-func (m *StreamReqData) XXX_DiscardUnknown() {
-	xxx_messageInfo_StreamReqData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_StreamReqData proto.InternalMessageInfo
-
-func (m *StreamReqData) GetServiceName() string {
-	if m != nil {
-		return m.ServiceName
-	}
-	return ""
-}
-
-func (m *StreamReqData) GetServiceIp() string {
-	if m != nil {
-		return m.ServiceIp
-	}
-	return ""
-}
-
-func (m *StreamReqData) GetServicePort() int32 {
-	if m != nil {
-		return m.ServicePort
-	}
-	return 0
-}
-
-//stream返回结构
-type StreamResData struct {
-	Data                 string   `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *StreamResData) Reset()         { *m = StreamResData{} }
-func (m *StreamResData) String() string { return proto.CompactTextString(m) }
-func (*StreamResData) ProtoMessage()    {}
-func (*StreamResData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_3c667767fb9826a9, []int{1}
-}
-
-func (m *StreamResData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_StreamResData.Unmarshal(m, b)
-}
-func (m *StreamResData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_StreamResData.Marshal(b, m, deterministic)
-}
-func (m *StreamResData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_StreamResData.Merge(m, src)
-}
-func (m *StreamResData) XXX_Size() int {
-	return xxx_messageInfo_StreamResData.Size(m)
-}
-func (m *StreamResData) XXX_DiscardUnknown() {
-	xxx_messageInfo_StreamResData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_StreamResData proto.InternalMessageInfo
-
-func (m *StreamResData) GetData() string {
-	if m != nil {
-		return m.Data
-	}
-	return ""
-}
-
-func init() {
-	proto.RegisterType((*StreamReqData)(nil), "proto.StreamReqData")
-	proto.RegisterType((*StreamResData)(nil), "proto.StreamResData")
-}
-
-func init() {
-	proto.RegisterFile("heartbeat.proto", fileDescriptor_3c667767fb9826a9)
-}
-
-var fileDescriptor_3c667767fb9826a9 = []byte{
-	// 174 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcf, 0x48, 0x4d, 0x2c,
-	0x2a, 0x49, 0x4a, 0x4d, 0x2c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a,
-	0x85, 0x5c, 0xbc, 0xc1, 0x25, 0x45, 0xa9, 0x89, 0xb9, 0x41, 0xa9, 0x85, 0x2e, 0x89, 0x25, 0x89,
-	0x42, 0x0a, 0x5c, 0xdc, 0xc5, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x7e, 0x89, 0xb9, 0xa9, 0x12,
-	0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0xc8, 0x42, 0x42, 0x32, 0x5c, 0x9c, 0x50, 0xae, 0x67, 0x81,
-	0x04, 0x13, 0x58, 0x1e, 0x21, 0x80, 0xa4, 0x3f, 0x20, 0xbf, 0xa8, 0x44, 0x82, 0x59, 0x81, 0x51,
-	0x83, 0x35, 0x08, 0x59, 0x48, 0x49, 0x19, 0x61, 0x65, 0x31, 0xd8, 0x4a, 0x21, 0x2e, 0x96, 0x94,
-	0xc4, 0x92, 0x44, 0xa8, 0x5d, 0x60, 0xb6, 0x91, 0x07, 0x17, 0xa7, 0x07, 0xc8, 0xc5, 0x4e, 0xa9,
-	0x89, 0x25, 0x42, 0xd6, 0x5c, 0x9c, 0x01, 0xa5, 0x25, 0x10, 0x4d, 0x42, 0x22, 0x10, 0x0f, 0xe8,
-	0xa1, 0x38, 0x5b, 0x0a, 0x5d, 0x14, 0x6c, 0xb2, 0x12, 0x83, 0x06, 0x63, 0x12, 0x1b, 0x58, 0xc2,
-	0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xce, 0x97, 0xa7, 0x35, 0x02, 0x01, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// HeartBeatClient is the client API for HeartBeat service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type HeartBeatClient interface {
-	PutStream(ctx context.Context, opts ...grpc.CallOption) (HeartBeat_PutStreamClient, error)
-}
-
-type heartBeatClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewHeartBeatClient(cc grpc.ClientConnInterface) HeartBeatClient {
-	return &heartBeatClient{cc}
-}
-
-func (c *heartBeatClient) PutStream(ctx context.Context, opts ...grpc.CallOption) (HeartBeat_PutStreamClient, error) {
-	stream, err := c.cc.NewStream(ctx, &_HeartBeat_serviceDesc.Streams[0], "/proto.HeartBeat/PutStream", opts...)
-	if err != nil {
-		return nil, err
-	}
-	x := &heartBeatPutStreamClient{stream}
-	return x, nil
-}
-
-type HeartBeat_PutStreamClient interface {
-	Send(*StreamReqData) error
-	CloseAndRecv() (*StreamResData, error)
-	grpc.ClientStream
-}
-
-type heartBeatPutStreamClient struct {
-	grpc.ClientStream
-}
-
-func (x *heartBeatPutStreamClient) Send(m *StreamReqData) error {
-	return x.ClientStream.SendMsg(m)
-}
-
-func (x *heartBeatPutStreamClient) CloseAndRecv() (*StreamResData, error) {
-	if err := x.ClientStream.CloseSend(); err != nil {
-		return nil, err
-	}
-	m := new(StreamResData)
-	if err := x.ClientStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-// HeartBeatServer is the server API for HeartBeat service.
-type HeartBeatServer interface {
-	PutStream(HeartBeat_PutStreamServer) error
-}
-
-// UnimplementedHeartBeatServer can be embedded to have forward compatible implementations.
-type UnimplementedHeartBeatServer struct {
-}
-
-func (*UnimplementedHeartBeatServer) PutStream(srv HeartBeat_PutStreamServer) error {
-	return status.Errorf(codes.Unimplemented, "method PutStream not implemented")
-}
-
-func RegisterHeartBeatServer(s *grpc.Server, srv HeartBeatServer) {
-	s.RegisterService(&_HeartBeat_serviceDesc, srv)
-}
-
-func _HeartBeat_PutStream_Handler(srv interface{}, stream grpc.ServerStream) error {
-	return srv.(HeartBeatServer).PutStream(&heartBeatPutStreamServer{stream})
-}
-
-type HeartBeat_PutStreamServer interface {
-	SendAndClose(*StreamResData) error
-	Recv() (*StreamReqData, error)
-	grpc.ServerStream
-}
-
-type heartBeatPutStreamServer struct {
-	grpc.ServerStream
-}
-
-func (x *heartBeatPutStreamServer) SendAndClose(m *StreamResData) error {
-	return x.ServerStream.SendMsg(m)
-}
-
-func (x *heartBeatPutStreamServer) Recv() (*StreamReqData, error) {
-	m := new(StreamReqData)
-	if err := x.ServerStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-var _HeartBeat_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "proto.HeartBeat",
-	HandlerType: (*HeartBeatServer)(nil),
-	Methods:     []grpc.MethodDesc{},
-	Streams: []grpc.StreamDesc{
-		{
-			StreamName:    "PutStream",
-			Handler:       _HeartBeat_PutStream_Handler,
-			ClientStreams: true,
-		},
-	},
-	Metadata: "heartbeat.proto",
-}

+ 0 - 206
download_file/src/serviced/proto/ocr.pb.go

@@ -1,206 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: ocr.proto
-
-//OCR图像转文字服务
-
-package proto
-
-import (
-	context "context"
-	fmt "fmt"
-	proto "github.com/golang/protobuf/proto"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-	math "math"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
-type OcrRequest struct {
-	Image                []byte   `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *OcrRequest) Reset()         { *m = OcrRequest{} }
-func (m *OcrRequest) String() string { return proto.CompactTextString(m) }
-func (*OcrRequest) ProtoMessage()    {}
-func (*OcrRequest) Descriptor() ([]byte, []int) {
-	return fileDescriptor_52282bc2e1d222c6, []int{0}
-}
-
-func (m *OcrRequest) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_OcrRequest.Unmarshal(m, b)
-}
-func (m *OcrRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_OcrRequest.Marshal(b, m, deterministic)
-}
-func (m *OcrRequest) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_OcrRequest.Merge(m, src)
-}
-func (m *OcrRequest) XXX_Size() int {
-	return xxx_messageInfo_OcrRequest.Size(m)
-}
-func (m *OcrRequest) XXX_DiscardUnknown() {
-	xxx_messageInfo_OcrRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_OcrRequest proto.InternalMessageInfo
-
-func (m *OcrRequest) GetImage() []byte {
-	if m != nil {
-		return m.Image
-	}
-	return nil
-}
-
-type OcrResponse struct {
-	Message              string   `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *OcrResponse) Reset()         { *m = OcrResponse{} }
-func (m *OcrResponse) String() string { return proto.CompactTextString(m) }
-func (*OcrResponse) ProtoMessage()    {}
-func (*OcrResponse) Descriptor() ([]byte, []int) {
-	return fileDescriptor_52282bc2e1d222c6, []int{1}
-}
-
-func (m *OcrResponse) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_OcrResponse.Unmarshal(m, b)
-}
-func (m *OcrResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_OcrResponse.Marshal(b, m, deterministic)
-}
-func (m *OcrResponse) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_OcrResponse.Merge(m, src)
-}
-func (m *OcrResponse) XXX_Size() int {
-	return xxx_messageInfo_OcrResponse.Size(m)
-}
-func (m *OcrResponse) XXX_DiscardUnknown() {
-	xxx_messageInfo_OcrResponse.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_OcrResponse proto.InternalMessageInfo
-
-func (m *OcrResponse) GetMessage() string {
-	if m != nil {
-		return m.Message
-	}
-	return ""
-}
-
-func init() {
-	proto.RegisterType((*OcrRequest)(nil), "proto.OcrRequest")
-	proto.RegisterType((*OcrResponse)(nil), "proto.OcrResponse")
-}
-
-func init() {
-	proto.RegisterFile("ocr.proto", fileDescriptor_52282bc2e1d222c6)
-}
-
-var fileDescriptor_52282bc2e1d222c6 = []byte{
-	// 124 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcc, 0x4f, 0x2e, 0xd2,
-	0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0x4a, 0x5c, 0x5c, 0xfe, 0xc9, 0x45,
-	0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x22, 0x5c, 0xac, 0x99, 0xb9, 0x89, 0xe9, 0xa9,
-	0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x3c, 0x41, 0x10, 0x8e, 0x92, 0x3a, 0x17, 0x37, 0x58, 0x4d, 0x71,
-	0x41, 0x7e, 0x5e, 0x71, 0xaa, 0x90, 0x04, 0x17, 0x7b, 0x6e, 0x6a, 0x71, 0x31, 0x4c, 0x19, 0x67,
-	0x10, 0x8c, 0x6b, 0x64, 0xcc, 0xc5, 0xec, 0x9f, 0x5c, 0x24, 0xa4, 0x03, 0xa1, 0x04, 0x21, 0x36,
-	0xe9, 0x21, 0xcc, 0x97, 0x12, 0x42, 0x16, 0x82, 0x18, 0x97, 0xc4, 0x06, 0x16, 0x32, 0x06, 0x04,
-	0x00, 0x00, 0xff, 0xff, 0xd9, 0x2d, 0xf8, 0xb2, 0x9c, 0x00, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// OcrClient is the client API for Ocr service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type OcrClient interface {
-	Ocr(ctx context.Context, in *OcrRequest, opts ...grpc.CallOption) (*OcrResponse, error)
-}
-
-type ocrClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewOcrClient(cc grpc.ClientConnInterface) OcrClient {
-	return &ocrClient{cc}
-}
-
-func (c *ocrClient) Ocr(ctx context.Context, in *OcrRequest, opts ...grpc.CallOption) (*OcrResponse, error) {
-	out := new(OcrResponse)
-	err := c.cc.Invoke(ctx, "/proto.Ocr/Ocr", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-// OcrServer is the server API for Ocr service.
-type OcrServer interface {
-	Ocr(context.Context, *OcrRequest) (*OcrResponse, error)
-}
-
-// UnimplementedOcrServer can be embedded to have forward compatible implementations.
-type UnimplementedOcrServer struct {
-}
-
-func (*UnimplementedOcrServer) Ocr(ctx context.Context, req *OcrRequest) (*OcrResponse, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method Ocr not implemented")
-}
-
-func RegisterOcrServer(s *grpc.Server, srv OcrServer) {
-	s.RegisterService(&_Ocr_serviceDesc, srv)
-}
-
-func _Ocr_Ocr_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(OcrRequest)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(OcrServer).Ocr(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/proto.Ocr/Ocr",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(OcrServer).Ocr(ctx, req.(*OcrRequest))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-var _Ocr_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "proto.Ocr",
-	HandlerType: (*OcrServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "Ocr",
-			Handler:    _Ocr_Ocr_Handler,
-		},
-	},
-	Streams:  []grpc.StreamDesc{},
-	Metadata: "ocr.proto",
-}

+ 0 - 252
download_file/src/serviced/proto/serverload.pb.go

@@ -1,252 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: serverload.proto
-
-//声明 包名
-
-package proto
-
-import (
-	context "context"
-	fmt "fmt"
-	proto "github.com/golang/protobuf/proto"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-	math "math"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
-//stream请求结构
-type ServerLoadStreamReqData struct {
-	Ip                   string   `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
-	Load                 float64  `protobuf:"fixed64,2,opt,name=load,proto3" json:"load,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *ServerLoadStreamReqData) Reset()         { *m = ServerLoadStreamReqData{} }
-func (m *ServerLoadStreamReqData) String() string { return proto.CompactTextString(m) }
-func (*ServerLoadStreamReqData) ProtoMessage()    {}
-func (*ServerLoadStreamReqData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_eb77c27475e52076, []int{0}
-}
-
-func (m *ServerLoadStreamReqData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_ServerLoadStreamReqData.Unmarshal(m, b)
-}
-func (m *ServerLoadStreamReqData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_ServerLoadStreamReqData.Marshal(b, m, deterministic)
-}
-func (m *ServerLoadStreamReqData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_ServerLoadStreamReqData.Merge(m, src)
-}
-func (m *ServerLoadStreamReqData) XXX_Size() int {
-	return xxx_messageInfo_ServerLoadStreamReqData.Size(m)
-}
-func (m *ServerLoadStreamReqData) XXX_DiscardUnknown() {
-	xxx_messageInfo_ServerLoadStreamReqData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ServerLoadStreamReqData proto.InternalMessageInfo
-
-func (m *ServerLoadStreamReqData) GetIp() string {
-	if m != nil {
-		return m.Ip
-	}
-	return ""
-}
-
-func (m *ServerLoadStreamReqData) GetLoad() float64 {
-	if m != nil {
-		return m.Load
-	}
-	return 0
-}
-
-//stream返回结构
-type ServerLoadStreamResData struct {
-	Code                 string   `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *ServerLoadStreamResData) Reset()         { *m = ServerLoadStreamResData{} }
-func (m *ServerLoadStreamResData) String() string { return proto.CompactTextString(m) }
-func (*ServerLoadStreamResData) ProtoMessage()    {}
-func (*ServerLoadStreamResData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_eb77c27475e52076, []int{1}
-}
-
-func (m *ServerLoadStreamResData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_ServerLoadStreamResData.Unmarshal(m, b)
-}
-func (m *ServerLoadStreamResData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_ServerLoadStreamResData.Marshal(b, m, deterministic)
-}
-func (m *ServerLoadStreamResData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_ServerLoadStreamResData.Merge(m, src)
-}
-func (m *ServerLoadStreamResData) XXX_Size() int {
-	return xxx_messageInfo_ServerLoadStreamResData.Size(m)
-}
-func (m *ServerLoadStreamResData) XXX_DiscardUnknown() {
-	xxx_messageInfo_ServerLoadStreamResData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ServerLoadStreamResData proto.InternalMessageInfo
-
-func (m *ServerLoadStreamResData) GetCode() string {
-	if m != nil {
-		return m.Code
-	}
-	return ""
-}
-
-func init() {
-	proto.RegisterType((*ServerLoadStreamReqData)(nil), "proto.ServerLoadStreamReqData")
-	proto.RegisterType((*ServerLoadStreamResData)(nil), "proto.ServerLoadStreamResData")
-}
-
-func init() {
-	proto.RegisterFile("serverload.proto", fileDescriptor_eb77c27475e52076)
-}
-
-var fileDescriptor_eb77c27475e52076 = []byte{
-	// 155 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x4e, 0x2d, 0x2a,
-	0x4b, 0x2d, 0xca, 0xc9, 0x4f, 0x4c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53,
-	0x4a, 0xb6, 0x5c, 0xe2, 0xc1, 0x60, 0x29, 0x9f, 0xfc, 0xc4, 0x94, 0xe0, 0x92, 0xa2, 0xd4, 0xc4,
-	0xdc, 0xa0, 0xd4, 0x42, 0x97, 0xc4, 0x92, 0x44, 0x21, 0x3e, 0x2e, 0xa6, 0xcc, 0x02, 0x09, 0x46,
-	0x05, 0x46, 0x0d, 0xce, 0x20, 0xa6, 0xcc, 0x02, 0x21, 0x21, 0x2e, 0x16, 0x90, 0x7e, 0x09, 0x26,
-	0x05, 0x46, 0x0d, 0xc6, 0x20, 0x30, 0x5b, 0x49, 0x17, 0x9b, 0xf6, 0x62, 0xb0, 0x76, 0x21, 0x2e,
-	0x96, 0xe4, 0xfc, 0x94, 0x54, 0xa8, 0x01, 0x60, 0xb6, 0x51, 0x2c, 0x17, 0x17, 0x42, 0xb9, 0x90,
-	0x3f, 0x17, 0x67, 0x40, 0x69, 0x09, 0x44, 0x97, 0x90, 0x1c, 0xc4, 0x5d, 0x7a, 0x38, 0x5c, 0x23,
-	0x85, 0x5b, 0x1e, 0x6c, 0x9d, 0x12, 0x83, 0x06, 0x63, 0x12, 0x1b, 0x58, 0x89, 0x31, 0x20, 0x00,
-	0x00, 0xff, 0xff, 0x6a, 0xae, 0x41, 0xc4, 0xee, 0x00, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// ServerLoadClient is the client API for ServerLoad service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type ServerLoadClient interface {
-	PutStream(ctx context.Context, opts ...grpc.CallOption) (ServerLoad_PutStreamClient, error)
-}
-
-type serverLoadClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewServerLoadClient(cc grpc.ClientConnInterface) ServerLoadClient {
-	return &serverLoadClient{cc}
-}
-
-func (c *serverLoadClient) PutStream(ctx context.Context, opts ...grpc.CallOption) (ServerLoad_PutStreamClient, error) {
-	stream, err := c.cc.NewStream(ctx, &_ServerLoad_serviceDesc.Streams[0], "/proto.ServerLoad/PutStream", opts...)
-	if err != nil {
-		return nil, err
-	}
-	x := &serverLoadPutStreamClient{stream}
-	return x, nil
-}
-
-type ServerLoad_PutStreamClient interface {
-	Send(*ServerLoadStreamReqData) error
-	CloseAndRecv() (*ServerLoadStreamResData, error)
-	grpc.ClientStream
-}
-
-type serverLoadPutStreamClient struct {
-	grpc.ClientStream
-}
-
-func (x *serverLoadPutStreamClient) Send(m *ServerLoadStreamReqData) error {
-	return x.ClientStream.SendMsg(m)
-}
-
-func (x *serverLoadPutStreamClient) CloseAndRecv() (*ServerLoadStreamResData, error) {
-	if err := x.ClientStream.CloseSend(); err != nil {
-		return nil, err
-	}
-	m := new(ServerLoadStreamResData)
-	if err := x.ClientStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-// ServerLoadServer is the server API for ServerLoad service.
-type ServerLoadServer interface {
-	PutStream(ServerLoad_PutStreamServer) error
-}
-
-// UnimplementedServerLoadServer can be embedded to have forward compatible implementations.
-type UnimplementedServerLoadServer struct {
-}
-
-func (*UnimplementedServerLoadServer) PutStream(srv ServerLoad_PutStreamServer) error {
-	return status.Errorf(codes.Unimplemented, "method PutStream not implemented")
-}
-
-func RegisterServerLoadServer(s *grpc.Server, srv ServerLoadServer) {
-	s.RegisterService(&_ServerLoad_serviceDesc, srv)
-}
-
-func _ServerLoad_PutStream_Handler(srv interface{}, stream grpc.ServerStream) error {
-	return srv.(ServerLoadServer).PutStream(&serverLoadPutStreamServer{stream})
-}
-
-type ServerLoad_PutStreamServer interface {
-	SendAndClose(*ServerLoadStreamResData) error
-	Recv() (*ServerLoadStreamReqData, error)
-	grpc.ServerStream
-}
-
-type serverLoadPutStreamServer struct {
-	grpc.ServerStream
-}
-
-func (x *serverLoadPutStreamServer) SendAndClose(m *ServerLoadStreamResData) error {
-	return x.ServerStream.SendMsg(m)
-}
-
-func (x *serverLoadPutStreamServer) Recv() (*ServerLoadStreamReqData, error) {
-	m := new(ServerLoadStreamReqData)
-	if err := x.ServerStream.RecvMsg(m); err != nil {
-		return nil, err
-	}
-	return m, nil
-}
-
-var _ServerLoad_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "proto.ServerLoad",
-	HandlerType: (*ServerLoadServer)(nil),
-	Methods:     []grpc.MethodDesc{},
-	Streams: []grpc.StreamDesc{
-		{
-			StreamName:    "PutStream",
-			Handler:       _ServerLoad_PutStream_Handler,
-			ClientStreams: true,
-		},
-	},
-	Metadata: "serverload.proto",
-}

+ 0 - 512
download_file/src/serviced/proto/service.pb.go

@@ -1,512 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: service.proto
-
-//声明 包名
-
-package proto
-
-import (
-	context "context"
-	fmt "fmt"
-	proto "github.com/golang/protobuf/proto"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
-	math "math"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
-
-//服务参数
-type ServiceMeta struct {
-	Name                 string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
-	Ip                   string   `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"`
-	Port                 int32    `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
-	Workers              int32    `protobuf:"varint,4,opt,name=workers,proto3" json:"workers,omitempty"`
-	Balance              int32    `protobuf:"varint,5,opt,name=balance,proto3" json:"balance,omitempty"`
-	Meta                 string   `protobuf:"bytes,6,opt,name=meta,proto3" json:"meta,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *ServiceMeta) Reset()         { *m = ServiceMeta{} }
-func (m *ServiceMeta) String() string { return proto.CompactTextString(m) }
-func (*ServiceMeta) ProtoMessage()    {}
-func (*ServiceMeta) Descriptor() ([]byte, []int) {
-	return fileDescriptor_a0b84a42fa06f626, []int{0}
-}
-
-func (m *ServiceMeta) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_ServiceMeta.Unmarshal(m, b)
-}
-func (m *ServiceMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_ServiceMeta.Marshal(b, m, deterministic)
-}
-func (m *ServiceMeta) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_ServiceMeta.Merge(m, src)
-}
-func (m *ServiceMeta) XXX_Size() int {
-	return xxx_messageInfo_ServiceMeta.Size(m)
-}
-func (m *ServiceMeta) XXX_DiscardUnknown() {
-	xxx_messageInfo_ServiceMeta.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ServiceMeta proto.InternalMessageInfo
-
-func (m *ServiceMeta) GetName() string {
-	if m != nil {
-		return m.Name
-	}
-	return ""
-}
-
-func (m *ServiceMeta) GetIp() string {
-	if m != nil {
-		return m.Ip
-	}
-	return ""
-}
-
-func (m *ServiceMeta) GetPort() int32 {
-	if m != nil {
-		return m.Port
-	}
-	return 0
-}
-
-func (m *ServiceMeta) GetWorkers() int32 {
-	if m != nil {
-		return m.Workers
-	}
-	return 0
-}
-
-func (m *ServiceMeta) GetBalance() int32 {
-	if m != nil {
-		return m.Balance
-	}
-	return 0
-}
-
-func (m *ServiceMeta) GetMeta() string {
-	if m != nil {
-		return m.Meta
-	}
-	return ""
-}
-
-//标准字符串返回结果
-type StringRepData struct {
-	Data                 string   `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *StringRepData) Reset()         { *m = StringRepData{} }
-func (m *StringRepData) String() string { return proto.CompactTextString(m) }
-func (*StringRepData) ProtoMessage()    {}
-func (*StringRepData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_a0b84a42fa06f626, []int{1}
-}
-
-func (m *StringRepData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_StringRepData.Unmarshal(m, b)
-}
-func (m *StringRepData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_StringRepData.Marshal(b, m, deterministic)
-}
-func (m *StringRepData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_StringRepData.Merge(m, src)
-}
-func (m *StringRepData) XXX_Size() int {
-	return xxx_messageInfo_StringRepData.Size(m)
-}
-func (m *StringRepData) XXX_DiscardUnknown() {
-	xxx_messageInfo_StringRepData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_StringRepData proto.InternalMessageInfo
-
-func (m *StringRepData) GetData() string {
-	if m != nil {
-		return m.Data
-	}
-	return ""
-}
-
-//标准字符串请求
-type StringReqData struct {
-	Data                 string   `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *StringReqData) Reset()         { *m = StringReqData{} }
-func (m *StringReqData) String() string { return proto.CompactTextString(m) }
-func (*StringReqData) ProtoMessage()    {}
-func (*StringReqData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_a0b84a42fa06f626, []int{2}
-}
-
-func (m *StringReqData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_StringReqData.Unmarshal(m, b)
-}
-func (m *StringReqData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_StringReqData.Marshal(b, m, deterministic)
-}
-func (m *StringReqData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_StringReqData.Merge(m, src)
-}
-func (m *StringReqData) XXX_Size() int {
-	return xxx_messageInfo_StringReqData.Size(m)
-}
-func (m *StringReqData) XXX_DiscardUnknown() {
-	xxx_messageInfo_StringReqData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_StringReqData proto.InternalMessageInfo
-
-func (m *StringReqData) GetData() string {
-	if m != nil {
-		return m.Data
-	}
-	return ""
-}
-
-//
-type ApplyReqData struct {
-	Name                 string   `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
-	Balance              int32    `protobuf:"varint,2,opt,name=balance,proto3" json:"balance,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *ApplyReqData) Reset()         { *m = ApplyReqData{} }
-func (m *ApplyReqData) String() string { return proto.CompactTextString(m) }
-func (*ApplyReqData) ProtoMessage()    {}
-func (*ApplyReqData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_a0b84a42fa06f626, []int{3}
-}
-
-func (m *ApplyReqData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_ApplyReqData.Unmarshal(m, b)
-}
-func (m *ApplyReqData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_ApplyReqData.Marshal(b, m, deterministic)
-}
-func (m *ApplyReqData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_ApplyReqData.Merge(m, src)
-}
-func (m *ApplyReqData) XXX_Size() int {
-	return xxx_messageInfo_ApplyReqData.Size(m)
-}
-func (m *ApplyReqData) XXX_DiscardUnknown() {
-	xxx_messageInfo_ApplyReqData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ApplyReqData proto.InternalMessageInfo
-
-func (m *ApplyReqData) GetName() string {
-	if m != nil {
-		return m.Name
-	}
-	return ""
-}
-
-func (m *ApplyReqData) GetBalance() int32 {
-	if m != nil {
-		return m.Balance
-	}
-	return 0
-}
-
-type ApplyRepData struct {
-	Ip                   string   `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
-	Port                 int32    `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
-}
-
-func (m *ApplyRepData) Reset()         { *m = ApplyRepData{} }
-func (m *ApplyRepData) String() string { return proto.CompactTextString(m) }
-func (*ApplyRepData) ProtoMessage()    {}
-func (*ApplyRepData) Descriptor() ([]byte, []int) {
-	return fileDescriptor_a0b84a42fa06f626, []int{4}
-}
-
-func (m *ApplyRepData) XXX_Unmarshal(b []byte) error {
-	return xxx_messageInfo_ApplyRepData.Unmarshal(m, b)
-}
-func (m *ApplyRepData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
-	return xxx_messageInfo_ApplyRepData.Marshal(b, m, deterministic)
-}
-func (m *ApplyRepData) XXX_Merge(src proto.Message) {
-	xxx_messageInfo_ApplyRepData.Merge(m, src)
-}
-func (m *ApplyRepData) XXX_Size() int {
-	return xxx_messageInfo_ApplyRepData.Size(m)
-}
-func (m *ApplyRepData) XXX_DiscardUnknown() {
-	xxx_messageInfo_ApplyRepData.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_ApplyRepData proto.InternalMessageInfo
-
-func (m *ApplyRepData) GetIp() string {
-	if m != nil {
-		return m.Ip
-	}
-	return ""
-}
-
-func (m *ApplyRepData) GetPort() int32 {
-	if m != nil {
-		return m.Port
-	}
-	return 0
-}
-
-func init() {
-	proto.RegisterType((*ServiceMeta)(nil), "proto.ServiceMeta")
-	proto.RegisterType((*StringRepData)(nil), "proto.StringRepData")
-	proto.RegisterType((*StringReqData)(nil), "proto.StringReqData")
-	proto.RegisterType((*ApplyReqData)(nil), "proto.ApplyReqData")
-	proto.RegisterType((*ApplyRepData)(nil), "proto.ApplyRepData")
-}
-
-func init() {
-	proto.RegisterFile("service.proto", fileDescriptor_a0b84a42fa06f626)
-}
-
-var fileDescriptor_a0b84a42fa06f626 = []byte{
-	// 279 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x50, 0xb1, 0x4e, 0xc3, 0x30,
-	0x10, 0xc5, 0xa6, 0x69, 0xc4, 0x41, 0x19, 0x0e, 0x06, 0xab, 0x53, 0x15, 0x96, 0x4e, 0x1d, 0x5a,
-	0xc1, 0xc4, 0x82, 0xd4, 0x95, 0x25, 0xfd, 0x02, 0xb7, 0x9c, 0x2a, 0x8b, 0x34, 0x36, 0xb6, 0x05,
-	0xea, 0x47, 0xf0, 0x97, 0x7c, 0x08, 0xb2, 0x9d, 0x80, 0xa1, 0x74, 0x60, 0xca, 0xf3, 0xbb, 0xf7,
-	0x72, 0xef, 0x1e, 0x8c, 0x1c, 0xd9, 0x57, 0xb5, 0xa1, 0x99, 0xb1, 0xda, 0x6b, 0x2c, 0xe2, 0xa7,
-	0x7a, 0x67, 0x70, 0xbe, 0x4a, 0x83, 0x47, 0xf2, 0x12, 0x11, 0x06, 0xad, 0xdc, 0x91, 0x60, 0x13,
-	0x36, 0x3d, 0xab, 0x23, 0xc6, 0x4b, 0xe0, 0xca, 0x08, 0x1e, 0x19, 0xae, 0x4c, 0xd0, 0x18, 0x6d,
-	0xbd, 0x38, 0x9d, 0xb0, 0x69, 0x51, 0x47, 0x8c, 0x02, 0xca, 0x37, 0x6d, 0x9f, 0xc9, 0x3a, 0x31,
-	0x88, 0x74, 0xff, 0x0c, 0x93, 0xb5, 0x6c, 0x64, 0xbb, 0x21, 0x51, 0xa4, 0x49, 0xf7, 0x0c, 0xff,
-	0xd9, 0x91, 0x97, 0x62, 0x98, 0x76, 0x05, 0x5c, 0xdd, 0xc0, 0x68, 0xe5, 0xad, 0x6a, 0xb7, 0x35,
-	0x99, 0xa5, 0x4c, 0x81, 0x9e, 0xa4, 0x97, 0x7d, 0xa0, 0x80, 0x73, 0xd1, 0xcb, 0x51, 0xd1, 0x3d,
-	0x5c, 0x3c, 0x18, 0xd3, 0xec, 0x33, 0xcd, 0xc1, 0x65, 0x59, 0x36, 0xfe, 0x23, 0x5b, 0x35, 0xff,
-	0x72, 0xa7, 0x18, 0xa9, 0x03, 0x76, 0xd0, 0x01, 0xff, 0xee, 0x60, 0xfe, 0xc1, 0xa0, 0xec, 0xba,
-	0xc4, 0x5b, 0x28, 0x6b, 0xda, 0x2a, 0xe7, 0x09, 0x31, 0x35, 0x3e, 0xcb, 0x6a, 0x1e, 0x5f, 0xf7,
-	0x5c, 0x7e, 0x6b, 0x75, 0x12, 0x6c, 0x4b, 0x72, 0x5e, 0xdb, 0xfd, 0xbf, 0x6c, 0x0b, 0x28, 0x62,
-	0x5a, 0xbc, 0xea, 0x04, 0xf9, 0xe5, 0xe3, 0x5f, 0x64, 0x6f, 0xba, 0x0b, 0x11, 0x1b, 0x92, 0x8e,
-	0xf0, 0x2f, 0xc5, 0xb1, 0x65, 0xeb, 0x61, 0xa4, 0x17, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x98,
-	0xb6, 0x0b, 0x2e, 0x51, 0x02, 0x00, 0x00,
-}
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// ServiceClient is the client API for Service service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type ServiceClient interface {
-	//注册服务
-	Registe(ctx context.Context, in *ServiceMeta, opts ...grpc.CallOption) (*StringRepData, error)
-	//注销服务
-	Destory(ctx context.Context, in *ServiceMeta, opts ...grpc.CallOption) (*StringRepData, error)
-	//申请服务
-	Apply(ctx context.Context, in *ApplyReqData, opts ...grpc.CallOption) (*ApplyRepData, error)
-	//释放服务
-	Release(ctx context.Context, in *ApplyRepData, opts ...grpc.CallOption) (*StringRepData, error)
-}
-
-type serviceClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient {
-	return &serviceClient{cc}
-}
-
-func (c *serviceClient) Registe(ctx context.Context, in *ServiceMeta, opts ...grpc.CallOption) (*StringRepData, error) {
-	out := new(StringRepData)
-	err := c.cc.Invoke(ctx, "/proto.Service/Registe", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *serviceClient) Destory(ctx context.Context, in *ServiceMeta, opts ...grpc.CallOption) (*StringRepData, error) {
-	out := new(StringRepData)
-	err := c.cc.Invoke(ctx, "/proto.Service/Destory", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *serviceClient) Apply(ctx context.Context, in *ApplyReqData, opts ...grpc.CallOption) (*ApplyRepData, error) {
-	out := new(ApplyRepData)
-	err := c.cc.Invoke(ctx, "/proto.Service/Apply", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *serviceClient) Release(ctx context.Context, in *ApplyRepData, opts ...grpc.CallOption) (*StringRepData, error) {
-	out := new(StringRepData)
-	err := c.cc.Invoke(ctx, "/proto.Service/Release", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-// ServiceServer is the server API for Service service.
-type ServiceServer interface {
-	//注册服务
-	Registe(context.Context, *ServiceMeta) (*StringRepData, error)
-	//注销服务
-	Destory(context.Context, *ServiceMeta) (*StringRepData, error)
-	//申请服务
-	Apply(context.Context, *ApplyReqData) (*ApplyRepData, error)
-	//释放服务
-	Release(context.Context, *ApplyRepData) (*StringRepData, error)
-}
-
-// UnimplementedServiceServer can be embedded to have forward compatible implementations.
-type UnimplementedServiceServer struct {
-}
-
-func (*UnimplementedServiceServer) Registe(ctx context.Context, req *ServiceMeta) (*StringRepData, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method Registe not implemented")
-}
-func (*UnimplementedServiceServer) Destory(ctx context.Context, req *ServiceMeta) (*StringRepData, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method Destory not implemented")
-}
-func (*UnimplementedServiceServer) Apply(ctx context.Context, req *ApplyReqData) (*ApplyRepData, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method Apply not implemented")
-}
-func (*UnimplementedServiceServer) Release(ctx context.Context, req *ApplyRepData) (*StringRepData, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method Release not implemented")
-}
-
-func RegisterServiceServer(s *grpc.Server, srv ServiceServer) {
-	s.RegisterService(&_Service_serviceDesc, srv)
-}
-
-func _Service_Registe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(ServiceMeta)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(ServiceServer).Registe(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/proto.Service/Registe",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(ServiceServer).Registe(ctx, req.(*ServiceMeta))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _Service_Destory_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(ServiceMeta)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(ServiceServer).Destory(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/proto.Service/Destory",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(ServiceServer).Destory(ctx, req.(*ServiceMeta))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _Service_Apply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(ApplyReqData)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(ServiceServer).Apply(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/proto.Service/Apply",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(ServiceServer).Apply(ctx, req.(*ApplyReqData))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _Service_Release_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(ApplyRepData)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(ServiceServer).Release(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/proto.Service/Release",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(ServiceServer).Release(ctx, req.(*ApplyRepData))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-var _Service_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "proto.Service",
-	HandlerType: (*ServiceServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "Registe",
-			Handler:    _Service_Registe_Handler,
-		},
-		{
-			MethodName: "Destory",
-			Handler:    _Service_Destory_Handler,
-		},
-		{
-			MethodName: "Apply",
-			Handler:    _Service_Apply_Handler,
-		},
-		{
-			MethodName: "Release",
-			Handler:    _Service_Release_Handler,
-		},
-	},
-	Streams:  []grpc.StreamDesc{},
-	Metadata: "service.proto",
-}

+ 0 - 41
download_file/src/serviced/serviced.go

@@ -1,41 +0,0 @@
-package serviced
-
-import (
-	"context"
-	"errors"
-	"fmt"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/credentials/insecure"
-	service "serviced/proto"
-	. "util"
-)
-
-func GetOcrServerConn() (*grpc.ClientConn, error) {
-	conn, err := grpc.Dial(OcrServerAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
-	if err != nil {
-		return nil, errors.New("Conn Ocr Server Error")
-	}
-	defer conn.Close()
-	ipClient := service.NewServiceClient(conn)
-	var serverIp string
-	var serverPort int
-	for i := 1; i <= 3; i++ { //重试
-		repl, err := ipClient.Apply(context.Background(), &service.ApplyReqData{Name: "file_service", Balance: 2})
-		if err != nil {
-			continue
-		} else {
-			serverIp = repl.Ip
-			serverPort = int(repl.Port)
-			break
-		}
-	}
-	if serverIp == "" || serverPort == 0 { //重试三次,ip、port失败
-		return nil, errors.New("Get Ip And Port Error")
-	}
-	addr := serverIp + ":" + fmt.Sprint(serverPort)
-	conn, err = grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
-	if err != nil {
-		return nil, errors.New("FileText Grpc Dial Error,addr:" + addr)
-	}
-	return conn, err
-}

+ 19 - 21
download_file/src/task.go

@@ -12,7 +12,6 @@ import (
 	"net/http"
 	qu "qfw/util"
 	"regexp"
-	"serviced"
 	sp "spiderutil"
 	"strings"
 	"sync"
@@ -259,7 +258,7 @@ func DealAndDownload(tmp []*Data, href string) (result []*Data, attachments, att
 				i := strings.Index(data.Url, ",")
 				dec := base64.NewDecoder(base64.StdEncoding, strings.NewReader(data.Url[i+1:]))
 				ret, err := io.ReadAll(dec)
-				if err == nil && len(ret) >= 1024*3 {
+				if err == nil && len(ret) >= 1024*3 && len(ret) < 15*1024*1024 {
 					fid := sp.GetHashKey(ret) + sp.TypeByExt(fileName)
 					bs := bytes.NewReader(ret)
 					size := qu.ConvertFileSize(bs.Len())
@@ -271,12 +270,16 @@ func DealAndDownload(tmp []*Data, href string) (result []*Data, attachments, att
 				}
 			} else {
 				contentType, ret := Download(data.Url) //下载
-				fileType := data.FileType              //从url或者text提取的附件类型
+				if len(ret) > 15*1024*1024 || len(ret) < 1024*3 {
+					qu.Debug("file size is too big or small!")
+					continue
+				}
+				fileType := data.FileType //从url或者text提取的附件类型
 				if fileType == "" {
 					fileType = GetType(contentType, ret) //获取附件类型
 					data.FileType = fileType
 				}
-				if fileType != "" && len(ret) >= 1024*3 {
+				if fileType != "" {
 					fileName := "附件" + fmt.Sprint(index+1) + "." + fileType
 					fid := sp.GetHashKey(ret) + sp.TypeByExt(fileName)
 					bs := bytes.NewReader(ret)
@@ -402,24 +405,19 @@ func GetAttachText(fid, fileName, fileType, url, size string, index int, ret []b
 		"url":      "oss",
 	}
 	//附件解析
-	conn, err := serviced.GetOcrServerConn() //链接ocr服务治理中心
-	if err == nil {
-		resp := GetFileText(conn, fileName, fid, fileType, ret)
-		if resp != nil {
-			tmap := map[string]interface{}{}
-			for i, r := range resp.Result {
-				rmap := map[string]interface{}{
-					"file_name":  r.FileName,
-					"attach_url": r.TextUrl,
-					"state":      r.ErrorState,
-				}
-				tmap[fmt.Sprint(i)] = rmap
-			}
-			if len(tmap) > 0 {
-				attachText[fmt.Sprint(index)] = tmap
+	resp := GetFileText(fileName, fid, fileType, ret)
+	if resp != nil {
+		tmap := map[string]interface{}{}
+		for i, r := range resp.Result {
+			rmap := map[string]interface{}{
+				"file_name":  r.FileName,
+				"attach_url": r.TextUrl,
+				"state":      r.ErrorState,
 			}
+			tmap[fmt.Sprint(i)] = rmap
+		}
+		if len(tmap) > 0 {
+			attachText[fmt.Sprint(index)] = tmap
 		}
-	} else {
-		qu.Debug("附件解析服务连接失败:", err)
 	}
 }