From ad1a05d66ec7cb533dba89cb183be9973058f2bd Mon Sep 17 00:00:00 2001 From: Adrian Liechti Date: Mon, 14 Oct 2024 15:27:21 +0200 Subject: [PATCH] finish index proto --- pkg/index/custom/client.go | 94 +++++- pkg/index/custom/index.pb.go | 539 +++++++++++++++++++----------- pkg/index/custom/index.proto | 36 +- pkg/index/custom/index_grpc.pb.go | 144 +++++++- 4 files changed, 583 insertions(+), 230 deletions(-) diff --git a/pkg/index/custom/client.go b/pkg/index/custom/client.go index 2a55029..b00f147 100644 --- a/pkg/index/custom/client.go +++ b/pkg/index/custom/client.go @@ -52,15 +52,29 @@ func New(url string, options ...Option) (*Client, error) { } func (c *Client) List(ctx context.Context, options *index.ListOptions) ([]index.Document, error) { - return nil, errors.ErrUnsupported + result, err := c.client.List(ctx, &ListRequest{}) + + if err != nil { + return nil, err + } + + return convertDocuments(result.Documents), nil } func (c *Client) Index(ctx context.Context, documents ...index.Document) error { - return errors.ErrUnsupported + _, err := c.client.Index(ctx, &IndexRequest{ + Documents: toDocuments(documents), + }) + + return err } func (c *Client) Delete(ctx context.Context, ids ...string) error { - return errors.ErrUnsupported + _, err := c.client.Delete(ctx, &DeleteRequest{ + Ids: ids, + }) + + return err } func (c *Client) Query(ctx context.Context, query string, options *index.QueryOptions) ([]index.Result, error) { @@ -85,27 +99,71 @@ func (c *Client) Query(ctx context.Context, query string, options *index.QueryOp return nil, err } - var results []index.Result + return convertResults(data.Results), nil +} + +func convertResult(r *Result) index.Result { + return index.Result{ + Score: r.Score, + Document: convertDocument(r.Document), + } +} + +func convertResults(s []*Result) []index.Result { + var result []index.Result - for _, r := range data.Results { - result := index.Result{ - Score: r.Score, + for _, r := range s { + result = append(result, convertResult(r)) + } - Document: index.Document{ - ID: r.Document.Id, + return result +} - Title: r.Document.Title, - Content: r.Document.Content, - Location: r.Document.Location, +func convertDocument(d *Document) index.Document { + return index.Document{ + ID: d.Id, - Metadata: r.Document.Metadata, + Title: d.Title, + Content: d.Content, + Location: d.Location, + + Metadata: d.Metadata, + + Embedding: d.Embedding, + } +} + +func convertDocuments(s []*Document) []index.Document { + var result []index.Document + + for _, d := range s { + result = append(result, convertDocument(d)) + } + + return result +} + +func toDocument(d index.Document) *Document { + return &Document{ + Id: d.ID, + + Title: d.Title, + Content: d.Content, + Location: d.Location, + + Metadata: d.Metadata, + + Embedding: d.Embedding, + } +} - Embedding: r.Document.Embedding, - }, - } +func toDocuments(s []index.Document) []*Document { + var result []*Document - results = append(results, result) + for _, d := range s { + document := toDocument(d) + result = append(result, document) } - return results, nil + return result } diff --git a/pkg/index/custom/index.pb.go b/pkg/index/custom/index.pb.go index 89c5714..c94f56b 100644 --- a/pkg/index/custom/index.pb.go +++ b/pkg/index/custom/index.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.1 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: index.proto package custom @@ -9,6 +9,7 @@ package custom import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" ) @@ -20,34 +21,28 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type QueryRequest struct { +type ListRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` - Limit *int32 `protobuf:"varint,2,opt,name=limit,proto3,oneof" json:"limit,omitempty"` - Filters map[string]string `protobuf:"bytes,3,rep,name=filters,proto3" json:"filters,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (x *QueryRequest) Reset() { - *x = QueryRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_index_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +func (x *ListRequest) Reset() { + *x = ListRequest{} + mi := &file_index_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (x *QueryRequest) String() string { +func (x *ListRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*QueryRequest) ProtoMessage() {} +func (*ListRequest) ProtoMessage() {} -func (x *QueryRequest) ProtoReflect() protoreflect.Message { +func (x *ListRequest) ProtoReflect() protoreflect.Message { mi := &file_index_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -57,58 +52,80 @@ func (x *QueryRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use QueryRequest.ProtoReflect.Descriptor instead. -func (*QueryRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead. +func (*ListRequest) Descriptor() ([]byte, []int) { return file_index_proto_rawDescGZIP(), []int{0} } -func (x *QueryRequest) GetQuery() string { +type DeleteRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"` +} + +func (x *DeleteRequest) Reset() { + *x = DeleteRequest{} + mi := &file_index_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRequest) ProtoMessage() {} + +func (x *DeleteRequest) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[1] if x != nil { - return x.Query + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return "" + return mi.MessageOf(x) } -func (x *QueryRequest) GetLimit() int32 { - if x != nil && x.Limit != nil { - return *x.Limit - } - return 0 +// Deprecated: Use DeleteRequest.ProtoReflect.Descriptor instead. +func (*DeleteRequest) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{1} } -func (x *QueryRequest) GetFilters() map[string]string { +func (x *DeleteRequest) GetIds() []string { if x != nil { - return x.Filters + return x.Ids } return nil } -type Results struct { +type IndexRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Results []*Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` + Documents []*Document `protobuf:"bytes,1,rep,name=documents,proto3" json:"documents,omitempty"` } -func (x *Results) Reset() { - *x = Results{} - if protoimpl.UnsafeEnabled { - mi := &file_index_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +func (x *IndexRequest) Reset() { + *x = IndexRequest{} + mi := &file_index_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (x *Results) String() string { +func (x *IndexRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Results) ProtoMessage() {} +func (*IndexRequest) ProtoMessage() {} -func (x *Results) ProtoReflect() protoreflect.Message { - mi := &file_index_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { +func (x *IndexRequest) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[2] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -118,45 +135,44 @@ func (x *Results) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Results.ProtoReflect.Descriptor instead. -func (*Results) Descriptor() ([]byte, []int) { - return file_index_proto_rawDescGZIP(), []int{1} +// Deprecated: Use IndexRequest.ProtoReflect.Descriptor instead. +func (*IndexRequest) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{2} } -func (x *Results) GetResults() []*Result { +func (x *IndexRequest) GetDocuments() []*Document { if x != nil { - return x.Results + return x.Documents } return nil } -type Result struct { +type QueryRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"` - Score float32 `protobuf:"fixed32,2,opt,name=score,proto3" json:"score,omitempty"` + Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` + Limit *int32 `protobuf:"varint,2,opt,name=limit,proto3,oneof" json:"limit,omitempty"` + Filters map[string]string `protobuf:"bytes,3,rep,name=filters,proto3" json:"filters,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (x *Result) Reset() { - *x = Result{} - if protoimpl.UnsafeEnabled { - mi := &file_index_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } +func (x *QueryRequest) Reset() { + *x = QueryRequest{} + mi := &file_index_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } -func (x *Result) String() string { +func (x *QueryRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Result) ProtoMessage() {} +func (*QueryRequest) ProtoMessage() {} -func (x *Result) ProtoReflect() protoreflect.Message { - mi := &file_index_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { +func (x *QueryRequest) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[3] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -166,23 +182,75 @@ func (x *Result) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Result.ProtoReflect.Descriptor instead. -func (*Result) Descriptor() ([]byte, []int) { - return file_index_proto_rawDescGZIP(), []int{2} +// Deprecated: Use QueryRequest.ProtoReflect.Descriptor instead. +func (*QueryRequest) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{3} } -func (x *Result) GetDocument() *Document { +func (x *QueryRequest) GetQuery() string { if x != nil { - return x.Document + return x.Query + } + return "" +} + +func (x *QueryRequest) GetLimit() int32 { + if x != nil && x.Limit != nil { + return *x.Limit + } + return 0 +} + +func (x *QueryRequest) GetFilters() map[string]string { + if x != nil { + return x.Filters } return nil } -func (x *Result) GetScore() float32 { +type Documents struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Documents []*Document `protobuf:"bytes,1,rep,name=documents,proto3" json:"documents,omitempty"` +} + +func (x *Documents) Reset() { + *x = Documents{} + mi := &file_index_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Documents) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Documents) ProtoMessage() {} + +func (x *Documents) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[4] if x != nil { - return x.Score + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 + return mi.MessageOf(x) +} + +// Deprecated: Use Documents.ProtoReflect.Descriptor instead. +func (*Documents) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{4} +} + +func (x *Documents) GetDocuments() []*Document { + if x != nil { + return x.Documents + } + return nil } type Document struct { @@ -200,11 +268,9 @@ type Document struct { func (x *Document) Reset() { *x = Document{} - if protoimpl.UnsafeEnabled { - mi := &file_index_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_index_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Document) String() string { @@ -214,8 +280,8 @@ func (x *Document) String() string { func (*Document) ProtoMessage() {} func (x *Document) ProtoReflect() protoreflect.Message { - mi := &file_index_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_index_proto_msgTypes[5] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -227,7 +293,7 @@ func (x *Document) ProtoReflect() protoreflect.Message { // Deprecated: Use Document.ProtoReflect.Descriptor instead. func (*Document) Descriptor() ([]byte, []int) { - return file_index_proto_rawDescGZIP(), []int{3} + return file_index_proto_rawDescGZIP(), []int{5} } func (x *Document) GetId() string { @@ -272,55 +338,175 @@ func (x *Document) GetEmbedding() []float32 { return nil } +type Results struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Results []*Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` +} + +func (x *Results) Reset() { + *x = Results{} + mi := &file_index_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Results) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Results) ProtoMessage() {} + +func (x *Results) ProtoReflect() protoreflect.Message { + mi := &file_index_proto_msgTypes[6] + 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 Results.ProtoReflect.Descriptor instead. +func (*Results) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{6} +} + +func (x *Results) GetResults() []*Result { + if x != nil { + return x.Results + } + return nil +} + +type Result struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Document *Document `protobuf:"bytes,1,opt,name=document,proto3" json:"document,omitempty"` + Score float32 `protobuf:"fixed32,2,opt,name=score,proto3" json:"score,omitempty"` +} + +func (x *Result) Reset() { + *x = Result{} + mi := &file_index_proto_msgTypes[7] + 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_index_proto_msgTypes[7] + 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 Result.ProtoReflect.Descriptor instead. +func (*Result) Descriptor() ([]byte, []int) { + return file_index_proto_rawDescGZIP(), []int{7} +} + +func (x *Result) GetDocument() *Document { + if x != nil { + return x.Document + } + return nil +} + +func (x *Result) GetScore() float32 { + if x != nil { + return x.Score + } + return 0 +} + var File_index_proto protoreflect.FileDescriptor var file_index_proto_rawDesc = []byte{ 0x0a, 0x0b, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x69, - 0x6e, 0x64, 0x65, 0x78, 0x22, 0xc1, 0x01, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x19, 0x0a, 0x05, 0x6c, - 0x69, 0x6d, 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x05, 0x6c, 0x69, - 0x6d, 0x69, 0x74, 0x88, 0x01, 0x01, 0x12, 0x3a, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, - 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x46, 0x69, 0x6c, - 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, - 0x72, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, - 0x0a, 0x06, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x32, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x73, 0x12, 0x27, 0x0a, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x4b, 0x0a, 0x06, - 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x2b, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, - 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, - 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x02, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x22, 0xfc, 0x01, 0x0a, 0x08, 0x44, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, - 0x09, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x06, 0x20, 0x03, 0x28, 0x02, - 0x52, 0x09, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0x37, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, - 0x78, 0x12, 0x2e, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x13, 0x2e, 0x69, 0x6e, 0x64, - 0x65, 0x78, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0e, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, - 0x00, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x61, 0x64, 0x72, 0x69, 0x61, 0x6e, 0x6c, 0x69, 0x65, 0x63, 0x68, 0x74, 0x69, 0x2f, 0x6c, 0x6c, - 0x61, 0x6d, 0x61, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x63, 0x75, - 0x73, 0x74, 0x6f, 0x6d, 0x3b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x6e, 0x64, 0x65, 0x78, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x21, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x10, 0x0a, 0x03, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, + 0x69, 0x64, 0x73, 0x22, 0x3d, 0x0a, 0x0c, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x22, 0xc1, 0x01, 0x0a, 0x0c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x19, 0x0a, 0x05, 0x6c, 0x69, 0x6d, + 0x69, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, + 0x74, 0x88, 0x01, 0x01, 0x12, 0x3a, 0x0a, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65, + 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, + 0x1a, 0x3a, 0x0a, 0x0c, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x08, 0x0a, 0x06, + 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x3a, 0x0a, 0x09, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x73, 0x12, 0x2d, 0x0a, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x09, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x22, 0xfc, 0x01, 0x0a, 0x08, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, + 0x1a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, + 0x69, 0x6e, 0x67, 0x18, 0x06, 0x20, 0x03, 0x28, 0x02, 0x52, 0x09, 0x65, 0x6d, 0x62, 0x65, 0x64, + 0x64, 0x69, 0x6e, 0x67, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x32, 0x0a, 0x07, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x12, 0x27, 0x0a, 0x07, + 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, + 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x07, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x4b, 0x0a, 0x06, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, + 0x2b, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0f, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0x6e, 0x74, 0x52, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, + 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x73, 0x63, 0x6f, + 0x72, 0x65, 0x32, 0xd9, 0x01, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x2e, 0x0a, 0x04, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x12, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x06, + 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x05, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x13, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x2e, + 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x13, 0x2e, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x73, 0x22, 0x00, 0x42, 0x38, + 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x72, + 0x69, 0x61, 0x6e, 0x6c, 0x69, 0x65, 0x63, 0x68, 0x74, 0x69, 0x2f, 0x6c, 0x6c, 0x61, 0x6d, 0x61, + 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, + 0x6d, 0x3b, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -335,27 +521,40 @@ func file_index_proto_rawDescGZIP() []byte { return file_index_proto_rawDescData } -var file_index_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_index_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_index_proto_goTypes = []any{ - (*QueryRequest)(nil), // 0: index.QueryRequest - (*Results)(nil), // 1: index.Results - (*Result)(nil), // 2: index.Result - (*Document)(nil), // 3: index.Document - nil, // 4: index.QueryRequest.FiltersEntry - nil, // 5: index.Document.MetadataEntry + (*ListRequest)(nil), // 0: index.ListRequest + (*DeleteRequest)(nil), // 1: index.DeleteRequest + (*IndexRequest)(nil), // 2: index.IndexRequest + (*QueryRequest)(nil), // 3: index.QueryRequest + (*Documents)(nil), // 4: index.Documents + (*Document)(nil), // 5: index.Document + (*Results)(nil), // 6: index.Results + (*Result)(nil), // 7: index.Result + nil, // 8: index.QueryRequest.FiltersEntry + nil, // 9: index.Document.MetadataEntry + (*emptypb.Empty)(nil), // 10: google.protobuf.Empty } var file_index_proto_depIdxs = []int32{ - 4, // 0: index.QueryRequest.filters:type_name -> index.QueryRequest.FiltersEntry - 2, // 1: index.Results.results:type_name -> index.Result - 3, // 2: index.Result.document:type_name -> index.Document - 5, // 3: index.Document.metadata:type_name -> index.Document.MetadataEntry - 0, // 4: index.index.Query:input_type -> index.QueryRequest - 1, // 5: index.index.Query:output_type -> index.Results - 5, // [5:6] is the sub-list for method output_type - 4, // [4:5] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 5, // 0: index.IndexRequest.documents:type_name -> index.Document + 8, // 1: index.QueryRequest.filters:type_name -> index.QueryRequest.FiltersEntry + 5, // 2: index.Documents.documents:type_name -> index.Document + 9, // 3: index.Document.metadata:type_name -> index.Document.MetadataEntry + 7, // 4: index.Results.results:type_name -> index.Result + 5, // 5: index.Result.document:type_name -> index.Document + 0, // 6: index.index.List:input_type -> index.ListRequest + 1, // 7: index.index.Delete:input_type -> index.DeleteRequest + 2, // 8: index.index.Index:input_type -> index.IndexRequest + 3, // 9: index.index.Query:input_type -> index.QueryRequest + 4, // 10: index.index.List:output_type -> index.Documents + 10, // 11: index.index.Delete:output_type -> google.protobuf.Empty + 10, // 12: index.index.Index:output_type -> google.protobuf.Empty + 6, // 13: index.index.Query:output_type -> index.Results + 10, // [10:14] is the sub-list for method output_type + 6, // [6:10] 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 } func init() { file_index_proto_init() } @@ -363,64 +562,14 @@ func file_index_proto_init() { if File_index_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_index_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*QueryRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_index_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Results); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_index_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Result); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_index_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*Document); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_index_proto_msgTypes[0].OneofWrappers = []any{} + file_index_proto_msgTypes[3].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_index_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/index/custom/index.proto b/pkg/index/custom/index.proto index 1d0fd65..6f400c4 100644 --- a/pkg/index/custom/index.proto +++ b/pkg/index/custom/index.proto @@ -1,13 +1,29 @@ syntax = "proto3"; +import "google/protobuf/empty.proto"; + option go_package = "github.com/adrianliechti/llama/pkg/index/custom;custom"; package index; service index { + rpc List (ListRequest) returns (Documents) {} + rpc Delete(DeleteRequest) returns (google.protobuf.Empty) {} + rpc Index(IndexRequest) returns (google.protobuf.Empty) {} rpc Query (QueryRequest) returns (Results) {} } +message ListRequest { +} + +message DeleteRequest { + repeated string ids = 1; +} + +message IndexRequest { + repeated Document documents = 1; +} + message QueryRequest { string query = 1; @@ -16,14 +32,8 @@ message QueryRequest { map filters = 3; } -message Results { - repeated Result results = 1; -} - -message Result { - Document document = 1; - - float score = 2; +message Documents { + repeated Document documents = 1; } message Document { @@ -37,3 +47,13 @@ message Document { repeated float embedding = 6; } + +message Results { + repeated Result results = 1; +} + +message Result { + Document document = 1; + + float score = 2; +} \ No newline at end of file diff --git a/pkg/index/custom/index_grpc.pb.go b/pkg/index/custom/index_grpc.pb.go index de1d8f5..550b84a 100644 --- a/pkg/index/custom/index_grpc.pb.go +++ b/pkg/index/custom/index_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.4.0 -// - protoc v5.27.1 +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.2 // source: index.proto package custom @@ -11,21 +11,28 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.62.0 or later. -const _ = grpc.SupportPackageIsVersion8 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( - Index_Query_FullMethodName = "/index.index/Query" + Index_List_FullMethodName = "/index.index/List" + Index_Delete_FullMethodName = "/index.index/Delete" + Index_Index_FullMethodName = "/index.index/Index" + Index_Query_FullMethodName = "/index.index/Query" ) // IndexClient is the client API for Index service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type IndexClient interface { + List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*Documents, error) + Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + Index(ctx context.Context, in *IndexRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*Results, error) } @@ -37,6 +44,36 @@ func NewIndexClient(cc grpc.ClientConnInterface) IndexClient { return &indexClient{cc} } +func (c *indexClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*Documents, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Documents) + err := c.cc.Invoke(ctx, Index_List_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *indexClient) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Index_Delete_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *indexClient) Index(ctx context.Context, in *IndexRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Index_Index_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *indexClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*Results, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Results) @@ -49,20 +86,36 @@ func (c *indexClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc. // IndexServer is the server API for Index service. // All implementations must embed UnimplementedIndexServer -// for forward compatibility +// for forward compatibility. type IndexServer interface { + List(context.Context, *ListRequest) (*Documents, error) + Delete(context.Context, *DeleteRequest) (*emptypb.Empty, error) + Index(context.Context, *IndexRequest) (*emptypb.Empty, error) Query(context.Context, *QueryRequest) (*Results, error) mustEmbedUnimplementedIndexServer() } -// UnimplementedIndexServer must be embedded to have forward compatible implementations. -type UnimplementedIndexServer struct { -} +// UnimplementedIndexServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedIndexServer struct{} +func (UnimplementedIndexServer) List(context.Context, *ListRequest) (*Documents, error) { + return nil, status.Errorf(codes.Unimplemented, "method List not implemented") +} +func (UnimplementedIndexServer) Delete(context.Context, *DeleteRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") +} +func (UnimplementedIndexServer) Index(context.Context, *IndexRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Index not implemented") +} func (UnimplementedIndexServer) Query(context.Context, *QueryRequest) (*Results, error) { return nil, status.Errorf(codes.Unimplemented, "method Query not implemented") } func (UnimplementedIndexServer) mustEmbedUnimplementedIndexServer() {} +func (UnimplementedIndexServer) testEmbeddedByValue() {} // UnsafeIndexServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to IndexServer will @@ -72,9 +125,70 @@ type UnsafeIndexServer interface { } func RegisterIndexServer(s grpc.ServiceRegistrar, srv IndexServer) { + // If the following call pancis, it indicates UnimplementedIndexServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&Index_ServiceDesc, srv) } +func _Index_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IndexServer).List(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Index_List_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IndexServer).List(ctx, req.(*ListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Index_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IndexServer).Delete(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Index_Delete_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IndexServer).Delete(ctx, req.(*DeleteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Index_Index_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IndexRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IndexServer).Index(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Index_Index_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IndexServer).Index(ctx, req.(*IndexRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Index_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryRequest) if err := dec(in); err != nil { @@ -100,6 +214,18 @@ var Index_ServiceDesc = grpc.ServiceDesc{ ServiceName: "index.index", HandlerType: (*IndexServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "List", + Handler: _Index_List_Handler, + }, + { + MethodName: "Delete", + Handler: _Index_Delete_Handler, + }, + { + MethodName: "Index", + Handler: _Index_Index_Handler, + }, { MethodName: "Query", Handler: _Index_Query_Handler,