feat(docreader): speed up scanned-PDF parsing, stream image results, isolate heavy async queues
Large scanned PDFs (hundreds of pages) were slow and fragile end-to-end.
This change addresses the parse, transport, and task-scheduling layers:
docreader (parse + transport):
- Parallelize per-page scanned rendering across processes (forkserver/fork),
with serial fallback. ~4-7x faster on large scanned PDFs; pdfium is not
thread-safe so we fan out across processes. Configurable via
DOCREADER_PDF_RENDER_PARALLELISM.
- Add server-streaming ReadStream RPC: emit one meta frame then one frame per
image, so documents with many page images are no longer capped by the unary
gRPC message-size limit (a 874-page PDF produced ~193MiB of images, far over
the 50MB cap) and memory is bounded on both ends. Unary Read is kept for
backward compatibility; the Go production reader switches to ReadStream.
VLM:
- Make the VLM HTTP timeout configurable (VLM_HTTP_TIMEOUT_SECONDS) and raise
the default 90s -> 180s so dense scanned-page OCR does not time out with
"context deadline exceeded".
Async task queues:
- Isolate high-volume, model-heavy fan-out tasks into dedicated asynq queues so
a single large document cannot saturate the shared worker pool and block
user-facing document parsing:
image:multimodal -> "multimodal"
chunk:extract -> "graph"
question:generation -> "question"
- Register the new queues in the server weight map and the cancel inspector's
scanned-queue set (so cancelling a knowledge still purges its pending tasks).
This commit is contained in:
+226
-37
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.6
|
||||
// protoc v6.33.4
|
||||
// protoc-gen-go v1.36.7
|
||||
// protoc v5.29.3
|
||||
// source: docreader.proto
|
||||
|
||||
package proto
|
||||
@@ -318,6 +318,167 @@ func (x *ReadResponse) GetError() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Metadata header for a streamed read. Sent exactly once, before any image.
|
||||
type ReadStreamMeta struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
MarkdownContent string `protobuf:"bytes,1,opt,name=markdown_content,json=markdownContent,proto3" json:"markdown_content,omitempty"`
|
||||
ImageDirPath string `protobuf:"bytes,2,opt,name=image_dir_path,json=imageDirPath,proto3" json:"image_dir_path,omitempty"`
|
||||
Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
|
||||
ImageCount uint32 `protobuf:"varint,5,opt,name=image_count,json=imageCount,proto3" json:"image_count,omitempty"` // best-effort total image count (0 if unknown)
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReadStreamMeta) Reset() {
|
||||
*x = ReadStreamMeta{}
|
||||
mi := &file_docreader_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReadStreamMeta) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadStreamMeta) ProtoMessage() {}
|
||||
|
||||
func (x *ReadStreamMeta) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[4]
|
||||
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 ReadStreamMeta.ProtoReflect.Descriptor instead.
|
||||
func (*ReadStreamMeta) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *ReadStreamMeta) GetMarkdownContent() string {
|
||||
if x != nil {
|
||||
return x.MarkdownContent
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReadStreamMeta) GetImageDirPath() string {
|
||||
if x != nil {
|
||||
return x.ImageDirPath
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReadStreamMeta) GetMetadata() map[string]string {
|
||||
if x != nil {
|
||||
return x.Metadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadStreamMeta) GetError() string {
|
||||
if x != nil {
|
||||
return x.Error
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ReadStreamMeta) GetImageCount() uint32 {
|
||||
if x != nil {
|
||||
return x.ImageCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// One frame of a ReadStream. The first frame carries `meta`; every subsequent
|
||||
// frame carries a single `image`.
|
||||
type ReadStreamResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Payload:
|
||||
//
|
||||
// *ReadStreamResponse_Meta
|
||||
// *ReadStreamResponse_Image
|
||||
Payload isReadStreamResponse_Payload `protobuf_oneof:"payload"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ReadStreamResponse) Reset() {
|
||||
*x = ReadStreamResponse{}
|
||||
mi := &file_docreader_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ReadStreamResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ReadStreamResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ReadStreamResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[5]
|
||||
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 ReadStreamResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ReadStreamResponse) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *ReadStreamResponse) GetPayload() isReadStreamResponse_Payload {
|
||||
if x != nil {
|
||||
return x.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadStreamResponse) GetMeta() *ReadStreamMeta {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*ReadStreamResponse_Meta); ok {
|
||||
return x.Meta
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ReadStreamResponse) GetImage() *ImageRef {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*ReadStreamResponse_Image); ok {
|
||||
return x.Image
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isReadStreamResponse_Payload interface {
|
||||
isReadStreamResponse_Payload()
|
||||
}
|
||||
|
||||
type ReadStreamResponse_Meta struct {
|
||||
Meta *ReadStreamMeta `protobuf:"bytes,1,opt,name=meta,proto3,oneof"`
|
||||
}
|
||||
|
||||
type ReadStreamResponse_Image struct {
|
||||
Image *ImageRef `protobuf:"bytes,2,opt,name=image,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*ReadStreamResponse_Meta) isReadStreamResponse_Payload() {}
|
||||
|
||||
func (*ReadStreamResponse_Image) isReadStreamResponse_Payload() {}
|
||||
|
||||
type ListEnginesRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
ConfigOverrides map[string]string `protobuf:"bytes,1,rep,name=config_overrides,json=configOverrides,proto3" json:"config_overrides,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
@@ -327,7 +488,7 @@ type ListEnginesRequest struct {
|
||||
|
||||
func (x *ListEnginesRequest) Reset() {
|
||||
*x = ListEnginesRequest{}
|
||||
mi := &file_docreader_proto_msgTypes[4]
|
||||
mi := &file_docreader_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -339,7 +500,7 @@ func (x *ListEnginesRequest) String() string {
|
||||
func (*ListEnginesRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListEnginesRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[4]
|
||||
mi := &file_docreader_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -352,7 +513,7 @@ func (x *ListEnginesRequest) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ListEnginesRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListEnginesRequest) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{4}
|
||||
return file_docreader_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *ListEnginesRequest) GetConfigOverrides() map[string]string {
|
||||
@@ -375,7 +536,7 @@ type ParserEngineInfo struct {
|
||||
|
||||
func (x *ParserEngineInfo) Reset() {
|
||||
*x = ParserEngineInfo{}
|
||||
mi := &file_docreader_proto_msgTypes[5]
|
||||
mi := &file_docreader_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -387,7 +548,7 @@ func (x *ParserEngineInfo) String() string {
|
||||
func (*ParserEngineInfo) ProtoMessage() {}
|
||||
|
||||
func (x *ParserEngineInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[5]
|
||||
mi := &file_docreader_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -400,7 +561,7 @@ func (x *ParserEngineInfo) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ParserEngineInfo.ProtoReflect.Descriptor instead.
|
||||
func (*ParserEngineInfo) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{5}
|
||||
return file_docreader_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *ParserEngineInfo) GetName() string {
|
||||
@@ -447,7 +608,7 @@ type ListEnginesResponse struct {
|
||||
|
||||
func (x *ListEnginesResponse) Reset() {
|
||||
*x = ListEnginesResponse{}
|
||||
mi := &file_docreader_proto_msgTypes[6]
|
||||
mi := &file_docreader_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -459,7 +620,7 @@ func (x *ListEnginesResponse) String() string {
|
||||
func (*ListEnginesResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListEnginesResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_docreader_proto_msgTypes[6]
|
||||
mi := &file_docreader_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -472,7 +633,7 @@ func (x *ListEnginesResponse) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use ListEnginesResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListEnginesResponse) Descriptor() ([]byte, []int) {
|
||||
return file_docreader_proto_rawDescGZIP(), []int{6}
|
||||
return file_docreader_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *ListEnginesResponse) GetEngines() []*ParserEngineInfo {
|
||||
@@ -520,7 +681,21 @@ const file_docreader_proto_rawDesc = "" +
|
||||
"\x05error\x18\x05 \x01(\tR\x05error\x1a;\n" +
|
||||
"\rMetadataEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xb7\x01\n" +
|
||||
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x9a\x02\n" +
|
||||
"\x0eReadStreamMeta\x12)\n" +
|
||||
"\x10markdown_content\x18\x01 \x01(\tR\x0fmarkdownContent\x12$\n" +
|
||||
"\x0eimage_dir_path\x18\x02 \x01(\tR\fimageDirPath\x12C\n" +
|
||||
"\bmetadata\x18\x03 \x03(\v2'.docreader.ReadStreamMeta.MetadataEntryR\bmetadata\x12\x14\n" +
|
||||
"\x05error\x18\x04 \x01(\tR\x05error\x12\x1f\n" +
|
||||
"\vimage_count\x18\x05 \x01(\rR\n" +
|
||||
"imageCount\x1a;\n" +
|
||||
"\rMetadataEntry\x12\x10\n" +
|
||||
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
|
||||
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"}\n" +
|
||||
"\x12ReadStreamResponse\x12/\n" +
|
||||
"\x04meta\x18\x01 \x01(\v2\x19.docreader.ReadStreamMetaH\x00R\x04meta\x12+\n" +
|
||||
"\x05image\x18\x02 \x01(\v2\x13.docreader.ImageRefH\x00R\x05imageB\t\n" +
|
||||
"\apayload\"\xb7\x01\n" +
|
||||
"\x12ListEnginesRequest\x12]\n" +
|
||||
"\x10config_overrides\x18\x01 \x03(\v22.docreader.ListEnginesRequest.ConfigOverridesEntryR\x0fconfigOverrides\x1aB\n" +
|
||||
"\x14ConfigOverridesEntry\x12\x10\n" +
|
||||
@@ -534,9 +709,11 @@ const file_docreader_proto_rawDesc = "" +
|
||||
"\tavailable\x18\x04 \x01(\bR\tavailable\x12-\n" +
|
||||
"\x12unavailable_reason\x18\x05 \x01(\tR\x11unavailableReason\"L\n" +
|
||||
"\x13ListEnginesResponse\x125\n" +
|
||||
"\aengines\x18\x01 \x03(\v2\x1b.docreader.ParserEngineInfoR\aengines2\x96\x01\n" +
|
||||
"\aengines\x18\x01 \x03(\v2\x1b.docreader.ParserEngineInfoR\aengines2\xdf\x01\n" +
|
||||
"\tDocReader\x129\n" +
|
||||
"\x04Read\x12\x16.docreader.ReadRequest\x1a\x17.docreader.ReadResponse\"\x00\x12N\n" +
|
||||
"\x04Read\x12\x16.docreader.ReadRequest\x1a\x17.docreader.ReadResponse\"\x00\x12G\n" +
|
||||
"\n" +
|
||||
"ReadStream\x12\x16.docreader.ReadRequest\x1a\x1d.docreader.ReadStreamResponse\"\x000\x01\x12N\n" +
|
||||
"\vListEngines\x12\x1d.docreader.ListEnginesRequest\x1a\x1e.docreader.ListEnginesResponse\"\x00B5Z3github.com/Tencent/WeKnora/internal/docreader/protob\x06proto3"
|
||||
|
||||
var (
|
||||
@@ -551,35 +728,43 @@ func file_docreader_proto_rawDescGZIP() []byte {
|
||||
return file_docreader_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_docreader_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_docreader_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
|
||||
var file_docreader_proto_goTypes = []any{
|
||||
(*ReadConfig)(nil), // 0: docreader.ReadConfig
|
||||
(*ReadRequest)(nil), // 1: docreader.ReadRequest
|
||||
(*ImageRef)(nil), // 2: docreader.ImageRef
|
||||
(*ReadResponse)(nil), // 3: docreader.ReadResponse
|
||||
(*ListEnginesRequest)(nil), // 4: docreader.ListEnginesRequest
|
||||
(*ParserEngineInfo)(nil), // 5: docreader.ParserEngineInfo
|
||||
(*ListEnginesResponse)(nil), // 6: docreader.ListEnginesResponse
|
||||
nil, // 7: docreader.ReadConfig.ParserEngineOverridesEntry
|
||||
nil, // 8: docreader.ReadResponse.MetadataEntry
|
||||
nil, // 9: docreader.ListEnginesRequest.ConfigOverridesEntry
|
||||
(*ReadStreamMeta)(nil), // 4: docreader.ReadStreamMeta
|
||||
(*ReadStreamResponse)(nil), // 5: docreader.ReadStreamResponse
|
||||
(*ListEnginesRequest)(nil), // 6: docreader.ListEnginesRequest
|
||||
(*ParserEngineInfo)(nil), // 7: docreader.ParserEngineInfo
|
||||
(*ListEnginesResponse)(nil), // 8: docreader.ListEnginesResponse
|
||||
nil, // 9: docreader.ReadConfig.ParserEngineOverridesEntry
|
||||
nil, // 10: docreader.ReadResponse.MetadataEntry
|
||||
nil, // 11: docreader.ReadStreamMeta.MetadataEntry
|
||||
nil, // 12: docreader.ListEnginesRequest.ConfigOverridesEntry
|
||||
}
|
||||
var file_docreader_proto_depIdxs = []int32{
|
||||
7, // 0: docreader.ReadConfig.parser_engine_overrides:type_name -> docreader.ReadConfig.ParserEngineOverridesEntry
|
||||
0, // 1: docreader.ReadRequest.config:type_name -> docreader.ReadConfig
|
||||
2, // 2: docreader.ReadResponse.image_refs:type_name -> docreader.ImageRef
|
||||
8, // 3: docreader.ReadResponse.metadata:type_name -> docreader.ReadResponse.MetadataEntry
|
||||
9, // 4: docreader.ListEnginesRequest.config_overrides:type_name -> docreader.ListEnginesRequest.ConfigOverridesEntry
|
||||
5, // 5: docreader.ListEnginesResponse.engines:type_name -> docreader.ParserEngineInfo
|
||||
1, // 6: docreader.DocReader.Read:input_type -> docreader.ReadRequest
|
||||
4, // 7: docreader.DocReader.ListEngines:input_type -> docreader.ListEnginesRequest
|
||||
3, // 8: docreader.DocReader.Read:output_type -> docreader.ReadResponse
|
||||
6, // 9: docreader.DocReader.ListEngines:output_type -> docreader.ListEnginesResponse
|
||||
8, // [8:10] is the sub-list for method output_type
|
||||
6, // [6:8] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
9, // 0: docreader.ReadConfig.parser_engine_overrides:type_name -> docreader.ReadConfig.ParserEngineOverridesEntry
|
||||
0, // 1: docreader.ReadRequest.config:type_name -> docreader.ReadConfig
|
||||
2, // 2: docreader.ReadResponse.image_refs:type_name -> docreader.ImageRef
|
||||
10, // 3: docreader.ReadResponse.metadata:type_name -> docreader.ReadResponse.MetadataEntry
|
||||
11, // 4: docreader.ReadStreamMeta.metadata:type_name -> docreader.ReadStreamMeta.MetadataEntry
|
||||
4, // 5: docreader.ReadStreamResponse.meta:type_name -> docreader.ReadStreamMeta
|
||||
2, // 6: docreader.ReadStreamResponse.image:type_name -> docreader.ImageRef
|
||||
12, // 7: docreader.ListEnginesRequest.config_overrides:type_name -> docreader.ListEnginesRequest.ConfigOverridesEntry
|
||||
7, // 8: docreader.ListEnginesResponse.engines:type_name -> docreader.ParserEngineInfo
|
||||
1, // 9: docreader.DocReader.Read:input_type -> docreader.ReadRequest
|
||||
1, // 10: docreader.DocReader.ReadStream:input_type -> docreader.ReadRequest
|
||||
6, // 11: docreader.DocReader.ListEngines:input_type -> docreader.ListEnginesRequest
|
||||
3, // 12: docreader.DocReader.Read:output_type -> docreader.ReadResponse
|
||||
5, // 13: docreader.DocReader.ReadStream:output_type -> docreader.ReadStreamResponse
|
||||
8, // 14: docreader.DocReader.ListEngines:output_type -> docreader.ListEnginesResponse
|
||||
12, // [12:15] is the sub-list for method output_type
|
||||
9, // [9:12] is the sub-list for method input_type
|
||||
9, // [9:9] is the sub-list for extension type_name
|
||||
9, // [9:9] is the sub-list for extension extendee
|
||||
0, // [0:9] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_docreader_proto_init() }
|
||||
@@ -587,13 +772,17 @@ func file_docreader_proto_init() {
|
||||
if File_docreader_proto != nil {
|
||||
return
|
||||
}
|
||||
file_docreader_proto_msgTypes[5].OneofWrappers = []any{
|
||||
(*ReadStreamResponse_Meta)(nil),
|
||||
(*ReadStreamResponse_Image)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_docreader_proto_rawDesc), len(file_docreader_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 10,
|
||||
NumMessages: 13,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
||||
@@ -6,6 +6,13 @@ option go_package = "github.com/Tencent/WeKnora/internal/docreader/proto";
|
||||
|
||||
service DocReader {
|
||||
rpc Read(ReadRequest) returns (ReadResponse) {}
|
||||
// ReadStream is the streaming counterpart of Read. It first emits one
|
||||
// ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
// error), then emits one message per image. This keeps every gRPC message
|
||||
// small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
// unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
// with bounded memory on both ends.
|
||||
rpc ReadStream(ReadRequest) returns (stream ReadStreamResponse) {}
|
||||
rpc ListEngines(ListEnginesRequest) returns (ListEnginesResponse) {}
|
||||
}
|
||||
|
||||
@@ -44,6 +51,24 @@ message ReadResponse {
|
||||
string error = 5;
|
||||
}
|
||||
|
||||
// Metadata header for a streamed read. Sent exactly once, before any image.
|
||||
message ReadStreamMeta {
|
||||
string markdown_content = 1;
|
||||
string image_dir_path = 2;
|
||||
map<string, string> metadata = 3;
|
||||
string error = 4;
|
||||
uint32 image_count = 5; // best-effort total image count (0 if unknown)
|
||||
}
|
||||
|
||||
// One frame of a ReadStream. The first frame carries `meta`; every subsequent
|
||||
// frame carries a single `image`.
|
||||
message ReadStreamResponse {
|
||||
oneof payload {
|
||||
ReadStreamMeta meta = 1;
|
||||
ImageRef image = 2;
|
||||
}
|
||||
}
|
||||
|
||||
message ListEnginesRequest {
|
||||
map<string, string> config_overrides = 1;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v6.33.4
|
||||
// - protoc v5.29.3
|
||||
// source: docreader.proto
|
||||
|
||||
package proto
|
||||
@@ -20,6 +20,7 @@ const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
DocReader_Read_FullMethodName = "/docreader.DocReader/Read"
|
||||
DocReader_ReadStream_FullMethodName = "/docreader.DocReader/ReadStream"
|
||||
DocReader_ListEngines_FullMethodName = "/docreader.DocReader/ListEngines"
|
||||
)
|
||||
|
||||
@@ -28,6 +29,13 @@ const (
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type DocReaderClient interface {
|
||||
Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (*ReadResponse, error)
|
||||
// ReadStream is the streaming counterpart of Read. It first emits one
|
||||
// ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
// error), then emits one message per image. This keeps every gRPC message
|
||||
// small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
// unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
// with bounded memory on both ends.
|
||||
ReadStream(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadStreamResponse], error)
|
||||
ListEngines(ctx context.Context, in *ListEnginesRequest, opts ...grpc.CallOption) (*ListEnginesResponse, error)
|
||||
}
|
||||
|
||||
@@ -49,6 +57,25 @@ func (c *docReaderClient) Read(ctx context.Context, in *ReadRequest, opts ...grp
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *docReaderClient) ReadStream(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ReadStreamResponse], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &DocReader_ServiceDesc.Streams[0], DocReader_ReadStream_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &grpc.GenericClientStream[ReadRequest, ReadStreamResponse]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := x.ClientStream.CloseSend(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type DocReader_ReadStreamClient = grpc.ServerStreamingClient[ReadStreamResponse]
|
||||
|
||||
func (c *docReaderClient) ListEngines(ctx context.Context, in *ListEnginesRequest, opts ...grpc.CallOption) (*ListEnginesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListEnginesResponse)
|
||||
@@ -64,6 +91,13 @@ func (c *docReaderClient) ListEngines(ctx context.Context, in *ListEnginesReques
|
||||
// for forward compatibility.
|
||||
type DocReaderServer interface {
|
||||
Read(context.Context, *ReadRequest) (*ReadResponse, error)
|
||||
// ReadStream is the streaming counterpart of Read. It first emits one
|
||||
// ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
// error), then emits one message per image. This keeps every gRPC message
|
||||
// small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
// unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
// with bounded memory on both ends.
|
||||
ReadStream(*ReadRequest, grpc.ServerStreamingServer[ReadStreamResponse]) error
|
||||
ListEngines(context.Context, *ListEnginesRequest) (*ListEnginesResponse, error)
|
||||
mustEmbedUnimplementedDocReaderServer()
|
||||
}
|
||||
@@ -78,6 +112,9 @@ type UnimplementedDocReaderServer struct{}
|
||||
func (UnimplementedDocReaderServer) Read(context.Context, *ReadRequest) (*ReadResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Read not implemented")
|
||||
}
|
||||
func (UnimplementedDocReaderServer) ReadStream(*ReadRequest, grpc.ServerStreamingServer[ReadStreamResponse]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ReadStream not implemented")
|
||||
}
|
||||
func (UnimplementedDocReaderServer) ListEngines(context.Context, *ListEnginesRequest) (*ListEnginesResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListEngines not implemented")
|
||||
}
|
||||
@@ -120,6 +157,17 @@ func _DocReader_Read_Handler(srv interface{}, ctx context.Context, dec func(inte
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DocReader_ReadStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
m := new(ReadRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(DocReaderServer).ReadStream(m, &grpc.GenericServerStream[ReadRequest, ReadStreamResponse]{ServerStream: stream})
|
||||
}
|
||||
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type DocReader_ReadStreamServer = grpc.ServerStreamingServer[ReadStreamResponse]
|
||||
|
||||
func _DocReader_ListEngines_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListEnginesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
@@ -154,6 +202,12 @@ var DocReader_ServiceDesc = grpc.ServiceDesc{
|
||||
Handler: _DocReader_ListEngines_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "ReadStream",
|
||||
Handler: _DocReader_ReadStream_Handler,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "docreader.proto",
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ _sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0f\x64ocreader.proto\x12\tdocreader\"\xba\x01\n\nReadConfig\x12\x15\n\rparser_engine\x18\x01 \x01(\t\x12Q\n\x17parser_engine_overrides\x18\x02 \x03(\x0b\x32\x30.docreader.ReadConfig.ParserEngineOverridesEntry\x1a<\n\x1aParserEngineOverridesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01J\x04\x08\x03\x10\x04\"\xa0\x01\n\x0bReadRequest\x12\x14\n\x0c\x66ile_content\x18\x01 \x01(\x0c\x12\x11\n\tfile_name\x18\x02 \x01(\t\x12\x11\n\tfile_type\x18\x03 \x01(\t\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\r\n\x05title\x18\x05 \x01(\t\x12%\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x15.docreader.ReadConfig\x12\x12\n\nrequest_id\x18\x07 \x01(\t\"n\n\x08ImageRef\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\x12\x14\n\x0coriginal_ref\x18\x02 \x01(\t\x12\x11\n\tmime_type\x18\x03 \x01(\t\x12\x13\n\x0bstorage_key\x18\x04 \x01(\t\x12\x12\n\nimage_data\x18\x05 \x01(\x0c\"\xe2\x01\n\x0cReadResponse\x12\x18\n\x10markdown_content\x18\x01 \x01(\t\x12\'\n\nimage_refs\x18\x02 \x03(\x0b\x32\x13.docreader.ImageRef\x12\x16\n\x0eimage_dir_path\x18\x03 \x01(\t\x12\x37\n\x08metadata\x18\x04 \x03(\x0b\x32%.docreader.ReadResponse.MetadataEntry\x12\r\n\x05\x65rror\x18\x05 \x01(\t\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x9a\x01\n\x12ListEnginesRequest\x12L\n\x10\x63onfig_overrides\x18\x01 \x03(\x0b\x32\x32.docreader.ListEnginesRequest.ConfigOverridesEntry\x1a\x36\n\x14\x43onfigOverridesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"x\n\x10ParserEngineInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x12\n\nfile_types\x18\x03 \x03(\t\x12\x11\n\tavailable\x18\x04 \x01(\x08\x12\x1a\n\x12unavailable_reason\x18\x05 \x01(\t\"C\n\x13ListEnginesResponse\x12,\n\x07\x65ngines\x18\x01 \x03(\x0b\x32\x1b.docreader.ParserEngineInfo2\x96\x01\n\tDocReader\x12\x39\n\x04Read\x12\x16.docreader.ReadRequest\x1a\x17.docreader.ReadResponse\"\x00\x12N\n\x0bListEngines\x12\x1d.docreader.ListEnginesRequest\x1a\x1e.docreader.ListEnginesResponse\"\x00\x42\x35Z3github.com/Tencent/WeKnora/internal/docreader/protob\x06proto3')
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0f\x64ocreader.proto\x12\tdocreader\"\xba\x01\n\nReadConfig\x12\x15\n\rparser_engine\x18\x01 \x01(\t\x12Q\n\x17parser_engine_overrides\x18\x02 \x03(\x0b\x32\x30.docreader.ReadConfig.ParserEngineOverridesEntry\x1a<\n\x1aParserEngineOverridesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01J\x04\x08\x03\x10\x04\"\xa0\x01\n\x0bReadRequest\x12\x14\n\x0c\x66ile_content\x18\x01 \x01(\x0c\x12\x11\n\tfile_name\x18\x02 \x01(\t\x12\x11\n\tfile_type\x18\x03 \x01(\t\x12\x0b\n\x03url\x18\x04 \x01(\t\x12\r\n\x05title\x18\x05 \x01(\t\x12%\n\x06\x63onfig\x18\x06 \x01(\x0b\x32\x15.docreader.ReadConfig\x12\x12\n\nrequest_id\x18\x07 \x01(\t\"n\n\x08ImageRef\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\x12\x14\n\x0coriginal_ref\x18\x02 \x01(\t\x12\x11\n\tmime_type\x18\x03 \x01(\t\x12\x13\n\x0bstorage_key\x18\x04 \x01(\t\x12\x12\n\nimage_data\x18\x05 \x01(\x0c\"\xe2\x01\n\x0cReadResponse\x12\x18\n\x10markdown_content\x18\x01 \x01(\t\x12\'\n\nimage_refs\x18\x02 \x03(\x0b\x32\x13.docreader.ImageRef\x12\x16\n\x0eimage_dir_path\x18\x03 \x01(\t\x12\x37\n\x08metadata\x18\x04 \x03(\x0b\x32%.docreader.ReadResponse.MetadataEntry\x12\r\n\x05\x65rror\x18\x05 \x01(\t\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xd2\x01\n\x0eReadStreamMeta\x12\x18\n\x10markdown_content\x18\x01 \x01(\t\x12\x16\n\x0eimage_dir_path\x18\x02 \x01(\t\x12\x39\n\x08metadata\x18\x03 \x03(\x0b\x32\'.docreader.ReadStreamMeta.MetadataEntry\x12\r\n\x05\x65rror\x18\x04 \x01(\t\x12\x13\n\x0bimage_count\x18\x05 \x01(\r\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"p\n\x12ReadStreamResponse\x12)\n\x04meta\x18\x01 \x01(\x0b\x32\x19.docreader.ReadStreamMetaH\x00\x12$\n\x05image\x18\x02 \x01(\x0b\x32\x13.docreader.ImageRefH\x00\x42\t\n\x07payload\"\x9a\x01\n\x12ListEnginesRequest\x12L\n\x10\x63onfig_overrides\x18\x01 \x03(\x0b\x32\x32.docreader.ListEnginesRequest.ConfigOverridesEntry\x1a\x36\n\x14\x43onfigOverridesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"x\n\x10ParserEngineInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x13\n\x0b\x64\x65scription\x18\x02 \x01(\t\x12\x12\n\nfile_types\x18\x03 \x03(\t\x12\x11\n\tavailable\x18\x04 \x01(\x08\x12\x1a\n\x12unavailable_reason\x18\x05 \x01(\t\"C\n\x13ListEnginesResponse\x12,\n\x07\x65ngines\x18\x01 \x03(\x0b\x32\x1b.docreader.ParserEngineInfo2\xdf\x01\n\tDocReader\x12\x39\n\x04Read\x12\x16.docreader.ReadRequest\x1a\x17.docreader.ReadResponse\"\x00\x12G\n\nReadStream\x12\x16.docreader.ReadRequest\x1a\x1d.docreader.ReadStreamResponse\"\x00\x30\x01\x12N\n\x0bListEngines\x12\x1d.docreader.ListEnginesRequest\x1a\x1e.docreader.ListEnginesResponse\"\x00\x42\x35Z3github.com/Tencent/WeKnora/internal/docreader/protob\x06proto3')
|
||||
|
||||
_globals = globals()
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
||||
@@ -36,6 +36,8 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
||||
_globals['_READCONFIG_PARSERENGINEOVERRIDESENTRY']._serialized_options = b'8\001'
|
||||
_globals['_READRESPONSE_METADATAENTRY']._loaded_options = None
|
||||
_globals['_READRESPONSE_METADATAENTRY']._serialized_options = b'8\001'
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._loaded_options = None
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._serialized_options = b'8\001'
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._loaded_options = None
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_options = b'8\001'
|
||||
_globals['_READCONFIG']._serialized_start=31
|
||||
@@ -50,14 +52,20 @@ if not _descriptor._USE_C_DESCRIPTORS:
|
||||
_globals['_READRESPONSE']._serialized_end=721
|
||||
_globals['_READRESPONSE_METADATAENTRY']._serialized_start=674
|
||||
_globals['_READRESPONSE_METADATAENTRY']._serialized_end=721
|
||||
_globals['_LISTENGINESREQUEST']._serialized_start=724
|
||||
_globals['_LISTENGINESREQUEST']._serialized_end=878
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_start=824
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_end=878
|
||||
_globals['_PARSERENGINEINFO']._serialized_start=880
|
||||
_globals['_PARSERENGINEINFO']._serialized_end=1000
|
||||
_globals['_LISTENGINESRESPONSE']._serialized_start=1002
|
||||
_globals['_LISTENGINESRESPONSE']._serialized_end=1069
|
||||
_globals['_DOCREADER']._serialized_start=1072
|
||||
_globals['_DOCREADER']._serialized_end=1222
|
||||
_globals['_READSTREAMMETA']._serialized_start=724
|
||||
_globals['_READSTREAMMETA']._serialized_end=934
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._serialized_start=674
|
||||
_globals['_READSTREAMMETA_METADATAENTRY']._serialized_end=721
|
||||
_globals['_READSTREAMRESPONSE']._serialized_start=936
|
||||
_globals['_READSTREAMRESPONSE']._serialized_end=1048
|
||||
_globals['_LISTENGINESREQUEST']._serialized_start=1051
|
||||
_globals['_LISTENGINESREQUEST']._serialized_end=1205
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_start=1151
|
||||
_globals['_LISTENGINESREQUEST_CONFIGOVERRIDESENTRY']._serialized_end=1205
|
||||
_globals['_PARSERENGINEINFO']._serialized_start=1207
|
||||
_globals['_PARSERENGINEINFO']._serialized_end=1327
|
||||
_globals['_LISTENGINESRESPONSE']._serialized_start=1329
|
||||
_globals['_LISTENGINESRESPONSE']._serialized_end=1396
|
||||
_globals['_DOCREADER']._serialized_start=1399
|
||||
_globals['_DOCREADER']._serialized_end=1622
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
||||
@@ -74,6 +74,35 @@ class ReadResponse(_message.Message):
|
||||
error: str
|
||||
def __init__(self, markdown_content: _Optional[str] = ..., image_refs: _Optional[_Iterable[_Union[ImageRef, _Mapping]]] = ..., image_dir_path: _Optional[str] = ..., metadata: _Optional[_Mapping[str, str]] = ..., error: _Optional[str] = ...) -> None: ...
|
||||
|
||||
class ReadStreamMeta(_message.Message):
|
||||
__slots__ = ("markdown_content", "image_dir_path", "metadata", "error", "image_count")
|
||||
class MetadataEntry(_message.Message):
|
||||
__slots__ = ("key", "value")
|
||||
KEY_FIELD_NUMBER: _ClassVar[int]
|
||||
VALUE_FIELD_NUMBER: _ClassVar[int]
|
||||
key: str
|
||||
value: str
|
||||
def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
|
||||
MARKDOWN_CONTENT_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_DIR_PATH_FIELD_NUMBER: _ClassVar[int]
|
||||
METADATA_FIELD_NUMBER: _ClassVar[int]
|
||||
ERROR_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_COUNT_FIELD_NUMBER: _ClassVar[int]
|
||||
markdown_content: str
|
||||
image_dir_path: str
|
||||
metadata: _containers.ScalarMap[str, str]
|
||||
error: str
|
||||
image_count: int
|
||||
def __init__(self, markdown_content: _Optional[str] = ..., image_dir_path: _Optional[str] = ..., metadata: _Optional[_Mapping[str, str]] = ..., error: _Optional[str] = ..., image_count: _Optional[int] = ...) -> None: ...
|
||||
|
||||
class ReadStreamResponse(_message.Message):
|
||||
__slots__ = ("meta", "image")
|
||||
META_FIELD_NUMBER: _ClassVar[int]
|
||||
IMAGE_FIELD_NUMBER: _ClassVar[int]
|
||||
meta: ReadStreamMeta
|
||||
image: ImageRef
|
||||
def __init__(self, meta: _Optional[_Union[ReadStreamMeta, _Mapping]] = ..., image: _Optional[_Union[ImageRef, _Mapping]] = ...) -> None: ...
|
||||
|
||||
class ListEnginesRequest(_message.Message):
|
||||
__slots__ = ("config_overrides",)
|
||||
class ConfigOverridesEntry(_message.Message):
|
||||
|
||||
@@ -5,7 +5,7 @@ import warnings
|
||||
|
||||
from docreader.proto import docreader_pb2 as docreader__pb2
|
||||
|
||||
GRPC_GENERATED_VERSION = '1.78.0'
|
||||
GRPC_GENERATED_VERSION = '1.80.0'
|
||||
GRPC_VERSION = grpc.__version__
|
||||
_version_not_supported = False
|
||||
|
||||
@@ -39,6 +39,11 @@ class DocReaderStub(object):
|
||||
request_serializer=docreader__pb2.ReadRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.ReadResponse.FromString,
|
||||
_registered_method=True)
|
||||
self.ReadStream = channel.unary_stream(
|
||||
'/docreader.DocReader/ReadStream',
|
||||
request_serializer=docreader__pb2.ReadRequest.SerializeToString,
|
||||
response_deserializer=docreader__pb2.ReadStreamResponse.FromString,
|
||||
_registered_method=True)
|
||||
self.ListEngines = channel.unary_unary(
|
||||
'/docreader.DocReader/ListEngines',
|
||||
request_serializer=docreader__pb2.ListEnginesRequest.SerializeToString,
|
||||
@@ -55,6 +60,18 @@ class DocReaderServicer(object):
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ReadStream(self, request, context):
|
||||
"""ReadStream is the streaming counterpart of Read. It first emits one
|
||||
ReadStreamResponse carrying the parse metadata (markdown / metadata /
|
||||
error), then emits one message per image. This keeps every gRPC message
|
||||
small so large scanned PDFs (hundreds of page images, far exceeding the
|
||||
unary message-size cap) can be returned without RESOURCE_EXHAUSTED and
|
||||
with bounded memory on both ends.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ListEngines(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
@@ -69,6 +86,11 @@ def add_DocReaderServicer_to_server(servicer, server):
|
||||
request_deserializer=docreader__pb2.ReadRequest.FromString,
|
||||
response_serializer=docreader__pb2.ReadResponse.SerializeToString,
|
||||
),
|
||||
'ReadStream': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.ReadStream,
|
||||
request_deserializer=docreader__pb2.ReadRequest.FromString,
|
||||
response_serializer=docreader__pb2.ReadStreamResponse.SerializeToString,
|
||||
),
|
||||
'ListEngines': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.ListEngines,
|
||||
request_deserializer=docreader__pb2.ListEnginesRequest.FromString,
|
||||
@@ -112,6 +134,33 @@ class DocReader(object):
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
|
||||
@staticmethod
|
||||
def ReadStream(request,
|
||||
target,
|
||||
options=(),
|
||||
channel_credentials=None,
|
||||
call_credentials=None,
|
||||
insecure=False,
|
||||
compression=None,
|
||||
wait_for_ready=None,
|
||||
timeout=None,
|
||||
metadata=None):
|
||||
return grpc.experimental.unary_stream(
|
||||
request,
|
||||
target,
|
||||
'/docreader.DocReader/ReadStream',
|
||||
docreader__pb2.ReadRequest.SerializeToString,
|
||||
docreader__pb2.ReadStreamResponse.FromString,
|
||||
options,
|
||||
channel_credentials,
|
||||
insecure,
|
||||
call_credentials,
|
||||
compression,
|
||||
wait_for_ready,
|
||||
timeout,
|
||||
metadata,
|
||||
_registered_method=True)
|
||||
|
||||
@staticmethod
|
||||
def ListEngines(request,
|
||||
target,
|
||||
|
||||
Reference in New Issue
Block a user