diff --git a/Makefile b/Makefile index 75f43ddc..f7e93f9d 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ export PATH=$(GOPATH)/bin:$(shell echo $$PATH) proto: $(MAKE) -C common proto $(MAKE) -C consensus proto + $(MAKE) -C client proto build: $(MAKE) -C node build diff --git a/client/Makefile b/client/Makefile new file mode 100644 index 00000000..0340fa3b --- /dev/null +++ b/client/Makefile @@ -0,0 +1,6 @@ +.PHONY: proto +export GOPRIVATE=github.com/anytypeio + +proto: + @$(eval GOGO_START := GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1) + $(GOGO_START) protoc --gogofaster_out=:. --go-drpc_out=protolib=github.com/gogo/protobuf:. api/apiproto/protos/*.proto \ No newline at end of file diff --git a/client/api/apiproto/api.pb.go b/client/api/apiproto/api.pb.go new file mode 100644 index 00000000..59eaeb5d --- /dev/null +++ b/client/api/apiproto/api.pb.go @@ -0,0 +1,3178 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: api/apiproto/protos/api.proto + +package apiproto + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// 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.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type CreateSpaceRequest struct { +} + +func (m *CreateSpaceRequest) Reset() { *m = CreateSpaceRequest{} } +func (m *CreateSpaceRequest) String() string { return proto.CompactTextString(m) } +func (*CreateSpaceRequest) ProtoMessage() {} +func (*CreateSpaceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{0} +} +func (m *CreateSpaceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreateSpaceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreateSpaceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CreateSpaceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateSpaceRequest.Merge(m, src) +} +func (m *CreateSpaceRequest) XXX_Size() int { + return m.Size() +} +func (m *CreateSpaceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CreateSpaceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateSpaceRequest proto.InternalMessageInfo + +type CreateSpaceResponse struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *CreateSpaceResponse) Reset() { *m = CreateSpaceResponse{} } +func (m *CreateSpaceResponse) String() string { return proto.CompactTextString(m) } +func (*CreateSpaceResponse) ProtoMessage() {} +func (*CreateSpaceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{1} +} +func (m *CreateSpaceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreateSpaceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreateSpaceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CreateSpaceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateSpaceResponse.Merge(m, src) +} +func (m *CreateSpaceResponse) XXX_Size() int { + return m.Size() +} +func (m *CreateSpaceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CreateSpaceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateSpaceResponse proto.InternalMessageInfo + +func (m *CreateSpaceResponse) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +type DeriveSpaceRequest struct { +} + +func (m *DeriveSpaceRequest) Reset() { *m = DeriveSpaceRequest{} } +func (m *DeriveSpaceRequest) String() string { return proto.CompactTextString(m) } +func (*DeriveSpaceRequest) ProtoMessage() {} +func (*DeriveSpaceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{2} +} +func (m *DeriveSpaceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeriveSpaceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeriveSpaceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeriveSpaceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeriveSpaceRequest.Merge(m, src) +} +func (m *DeriveSpaceRequest) XXX_Size() int { + return m.Size() +} +func (m *DeriveSpaceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeriveSpaceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeriveSpaceRequest proto.InternalMessageInfo + +type DeriveSpaceResponse struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *DeriveSpaceResponse) Reset() { *m = DeriveSpaceResponse{} } +func (m *DeriveSpaceResponse) String() string { return proto.CompactTextString(m) } +func (*DeriveSpaceResponse) ProtoMessage() {} +func (*DeriveSpaceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{3} +} +func (m *DeriveSpaceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeriveSpaceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeriveSpaceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeriveSpaceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeriveSpaceResponse.Merge(m, src) +} +func (m *DeriveSpaceResponse) XXX_Size() int { + return m.Size() +} +func (m *DeriveSpaceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DeriveSpaceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DeriveSpaceResponse proto.InternalMessageInfo + +func (m *DeriveSpaceResponse) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +type CreateDocumentRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` +} + +func (m *CreateDocumentRequest) Reset() { *m = CreateDocumentRequest{} } +func (m *CreateDocumentRequest) String() string { return proto.CompactTextString(m) } +func (*CreateDocumentRequest) ProtoMessage() {} +func (*CreateDocumentRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{4} +} +func (m *CreateDocumentRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreateDocumentRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreateDocumentRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CreateDocumentRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateDocumentRequest.Merge(m, src) +} +func (m *CreateDocumentRequest) XXX_Size() int { + return m.Size() +} +func (m *CreateDocumentRequest) XXX_DiscardUnknown() { + xxx_messageInfo_CreateDocumentRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateDocumentRequest proto.InternalMessageInfo + +func (m *CreateDocumentRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +type CreateDocumentResponse struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *CreateDocumentResponse) Reset() { *m = CreateDocumentResponse{} } +func (m *CreateDocumentResponse) String() string { return proto.CompactTextString(m) } +func (*CreateDocumentResponse) ProtoMessage() {} +func (*CreateDocumentResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{5} +} +func (m *CreateDocumentResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CreateDocumentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CreateDocumentResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CreateDocumentResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_CreateDocumentResponse.Merge(m, src) +} +func (m *CreateDocumentResponse) XXX_Size() int { + return m.Size() +} +func (m *CreateDocumentResponse) XXX_DiscardUnknown() { + xxx_messageInfo_CreateDocumentResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_CreateDocumentResponse proto.InternalMessageInfo + +func (m *CreateDocumentResponse) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +type DeleteDocumentRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + DocumentId string `protobuf:"bytes,2,opt,name=documentId,proto3" json:"documentId,omitempty"` +} + +func (m *DeleteDocumentRequest) Reset() { *m = DeleteDocumentRequest{} } +func (m *DeleteDocumentRequest) String() string { return proto.CompactTextString(m) } +func (*DeleteDocumentRequest) ProtoMessage() {} +func (*DeleteDocumentRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{6} +} +func (m *DeleteDocumentRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteDocumentRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteDocumentRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeleteDocumentRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteDocumentRequest.Merge(m, src) +} +func (m *DeleteDocumentRequest) XXX_Size() int { + return m.Size() +} +func (m *DeleteDocumentRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteDocumentRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteDocumentRequest proto.InternalMessageInfo + +func (m *DeleteDocumentRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *DeleteDocumentRequest) GetDocumentId() string { + if m != nil { + return m.DocumentId + } + return "" +} + +type DeleteDocumentResponse struct { +} + +func (m *DeleteDocumentResponse) Reset() { *m = DeleteDocumentResponse{} } +func (m *DeleteDocumentResponse) String() string { return proto.CompactTextString(m) } +func (*DeleteDocumentResponse) ProtoMessage() {} +func (*DeleteDocumentResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{7} +} +func (m *DeleteDocumentResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DeleteDocumentResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DeleteDocumentResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DeleteDocumentResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DeleteDocumentResponse.Merge(m, src) +} +func (m *DeleteDocumentResponse) XXX_Size() int { + return m.Size() +} +func (m *DeleteDocumentResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DeleteDocumentResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DeleteDocumentResponse proto.InternalMessageInfo + +type AddTextRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + DocumentId string `protobuf:"bytes,2,opt,name=documentId,proto3" json:"documentId,omitempty"` + Text string `protobuf:"bytes,3,opt,name=text,proto3" json:"text,omitempty"` +} + +func (m *AddTextRequest) Reset() { *m = AddTextRequest{} } +func (m *AddTextRequest) String() string { return proto.CompactTextString(m) } +func (*AddTextRequest) ProtoMessage() {} +func (*AddTextRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{8} +} +func (m *AddTextRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddTextRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddTextRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AddTextRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddTextRequest.Merge(m, src) +} +func (m *AddTextRequest) XXX_Size() int { + return m.Size() +} +func (m *AddTextRequest) XXX_DiscardUnknown() { + xxx_messageInfo_AddTextRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_AddTextRequest proto.InternalMessageInfo + +func (m *AddTextRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *AddTextRequest) GetDocumentId() string { + if m != nil { + return m.DocumentId + } + return "" +} + +func (m *AddTextRequest) GetText() string { + if m != nil { + return m.Text + } + return "" +} + +type AddTextResponse struct { + DocumentId string `protobuf:"bytes,1,opt,name=documentId,proto3" json:"documentId,omitempty"` + HeadId string `protobuf:"bytes,2,opt,name=headId,proto3" json:"headId,omitempty"` +} + +func (m *AddTextResponse) Reset() { *m = AddTextResponse{} } +func (m *AddTextResponse) String() string { return proto.CompactTextString(m) } +func (*AddTextResponse) ProtoMessage() {} +func (*AddTextResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{9} +} +func (m *AddTextResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AddTextResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AddTextResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AddTextResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddTextResponse.Merge(m, src) +} +func (m *AddTextResponse) XXX_Size() int { + return m.Size() +} +func (m *AddTextResponse) XXX_DiscardUnknown() { + xxx_messageInfo_AddTextResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_AddTextResponse proto.InternalMessageInfo + +func (m *AddTextResponse) GetDocumentId() string { + if m != nil { + return m.DocumentId + } + return "" +} + +func (m *AddTextResponse) GetHeadId() string { + if m != nil { + return m.HeadId + } + return "" +} + +type DumpTreeRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + DocumentId string `protobuf:"bytes,2,opt,name=documentId,proto3" json:"documentId,omitempty"` +} + +func (m *DumpTreeRequest) Reset() { *m = DumpTreeRequest{} } +func (m *DumpTreeRequest) String() string { return proto.CompactTextString(m) } +func (*DumpTreeRequest) ProtoMessage() {} +func (*DumpTreeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{10} +} +func (m *DumpTreeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DumpTreeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DumpTreeRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DumpTreeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DumpTreeRequest.Merge(m, src) +} +func (m *DumpTreeRequest) XXX_Size() int { + return m.Size() +} +func (m *DumpTreeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DumpTreeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DumpTreeRequest proto.InternalMessageInfo + +func (m *DumpTreeRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *DumpTreeRequest) GetDocumentId() string { + if m != nil { + return m.DocumentId + } + return "" +} + +type DumpTreeResponse struct { + Dump string `protobuf:"bytes,1,opt,name=dump,proto3" json:"dump,omitempty"` +} + +func (m *DumpTreeResponse) Reset() { *m = DumpTreeResponse{} } +func (m *DumpTreeResponse) String() string { return proto.CompactTextString(m) } +func (*DumpTreeResponse) ProtoMessage() {} +func (*DumpTreeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{11} +} +func (m *DumpTreeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DumpTreeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DumpTreeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DumpTreeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DumpTreeResponse.Merge(m, src) +} +func (m *DumpTreeResponse) XXX_Size() int { + return m.Size() +} +func (m *DumpTreeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DumpTreeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DumpTreeResponse proto.InternalMessageInfo + +func (m *DumpTreeResponse) GetDump() string { + if m != nil { + return m.Dump + } + return "" +} + +type AllTreesRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` +} + +func (m *AllTreesRequest) Reset() { *m = AllTreesRequest{} } +func (m *AllTreesRequest) String() string { return proto.CompactTextString(m) } +func (*AllTreesRequest) ProtoMessage() {} +func (*AllTreesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{12} +} +func (m *AllTreesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllTreesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllTreesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AllTreesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllTreesRequest.Merge(m, src) +} +func (m *AllTreesRequest) XXX_Size() int { + return m.Size() +} +func (m *AllTreesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_AllTreesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_AllTreesRequest proto.InternalMessageInfo + +func (m *AllTreesRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +type Tree struct { + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Heads []string `protobuf:"bytes,2,rep,name=heads,proto3" json:"heads,omitempty"` +} + +func (m *Tree) Reset() { *m = Tree{} } +func (m *Tree) String() string { return proto.CompactTextString(m) } +func (*Tree) ProtoMessage() {} +func (*Tree) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{13} +} +func (m *Tree) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Tree) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Tree.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Tree) XXX_Merge(src proto.Message) { + xxx_messageInfo_Tree.Merge(m, src) +} +func (m *Tree) XXX_Size() int { + return m.Size() +} +func (m *Tree) XXX_DiscardUnknown() { + xxx_messageInfo_Tree.DiscardUnknown(m) +} + +var xxx_messageInfo_Tree proto.InternalMessageInfo + +func (m *Tree) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *Tree) GetHeads() []string { + if m != nil { + return m.Heads + } + return nil +} + +type AllTreesResponse struct { + Trees []*Tree `protobuf:"bytes,1,rep,name=trees,proto3" json:"trees,omitempty"` +} + +func (m *AllTreesResponse) Reset() { *m = AllTreesResponse{} } +func (m *AllTreesResponse) String() string { return proto.CompactTextString(m) } +func (*AllTreesResponse) ProtoMessage() {} +func (*AllTreesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{14} +} +func (m *AllTreesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllTreesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllTreesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AllTreesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllTreesResponse.Merge(m, src) +} +func (m *AllTreesResponse) XXX_Size() int { + return m.Size() +} +func (m *AllTreesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_AllTreesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_AllTreesResponse proto.InternalMessageInfo + +func (m *AllTreesResponse) GetTrees() []*Tree { + if m != nil { + return m.Trees + } + return nil +} + +type AllSpacesRequest struct { +} + +func (m *AllSpacesRequest) Reset() { *m = AllSpacesRequest{} } +func (m *AllSpacesRequest) String() string { return proto.CompactTextString(m) } +func (*AllSpacesRequest) ProtoMessage() {} +func (*AllSpacesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{15} +} +func (m *AllSpacesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllSpacesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllSpacesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AllSpacesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllSpacesRequest.Merge(m, src) +} +func (m *AllSpacesRequest) XXX_Size() int { + return m.Size() +} +func (m *AllSpacesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_AllSpacesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_AllSpacesRequest proto.InternalMessageInfo + +type AllSpacesResponse struct { + SpaceIds []string `protobuf:"bytes,1,rep,name=spaceIds,proto3" json:"spaceIds,omitempty"` +} + +func (m *AllSpacesResponse) Reset() { *m = AllSpacesResponse{} } +func (m *AllSpacesResponse) String() string { return proto.CompactTextString(m) } +func (*AllSpacesResponse) ProtoMessage() {} +func (*AllSpacesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fc31080c27db9707, []int{16} +} +func (m *AllSpacesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AllSpacesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AllSpacesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AllSpacesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_AllSpacesResponse.Merge(m, src) +} +func (m *AllSpacesResponse) XXX_Size() int { + return m.Size() +} +func (m *AllSpacesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_AllSpacesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_AllSpacesResponse proto.InternalMessageInfo + +func (m *AllSpacesResponse) GetSpaceIds() []string { + if m != nil { + return m.SpaceIds + } + return nil +} + +func init() { + proto.RegisterType((*CreateSpaceRequest)(nil), "api.CreateSpaceRequest") + proto.RegisterType((*CreateSpaceResponse)(nil), "api.CreateSpaceResponse") + proto.RegisterType((*DeriveSpaceRequest)(nil), "api.DeriveSpaceRequest") + proto.RegisterType((*DeriveSpaceResponse)(nil), "api.DeriveSpaceResponse") + proto.RegisterType((*CreateDocumentRequest)(nil), "api.CreateDocumentRequest") + proto.RegisterType((*CreateDocumentResponse)(nil), "api.CreateDocumentResponse") + proto.RegisterType((*DeleteDocumentRequest)(nil), "api.DeleteDocumentRequest") + proto.RegisterType((*DeleteDocumentResponse)(nil), "api.DeleteDocumentResponse") + proto.RegisterType((*AddTextRequest)(nil), "api.AddTextRequest") + proto.RegisterType((*AddTextResponse)(nil), "api.AddTextResponse") + proto.RegisterType((*DumpTreeRequest)(nil), "api.DumpTreeRequest") + proto.RegisterType((*DumpTreeResponse)(nil), "api.DumpTreeResponse") + proto.RegisterType((*AllTreesRequest)(nil), "api.AllTreesRequest") + proto.RegisterType((*Tree)(nil), "api.Tree") + proto.RegisterType((*AllTreesResponse)(nil), "api.AllTreesResponse") + proto.RegisterType((*AllSpacesRequest)(nil), "api.AllSpacesRequest") + proto.RegisterType((*AllSpacesResponse)(nil), "api.AllSpacesResponse") +} + +func init() { proto.RegisterFile("api/apiproto/protos/api.proto", fileDescriptor_fc31080c27db9707) } + +var fileDescriptor_fc31080c27db9707 = []byte{ + // 517 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4d, 0x8f, 0xd2, 0x50, + 0x14, 0xa5, 0xc0, 0x7c, 0xf4, 0x60, 0x60, 0xbc, 0x03, 0xd8, 0xd4, 0x58, 0xc9, 0x4b, 0x9c, 0x90, + 0x68, 0x86, 0x38, 0x63, 0x62, 0xe2, 0x6a, 0x70, 0xd8, 0x10, 0x57, 0xe2, 0xac, 0x5c, 0x98, 0xd4, + 0xe9, 0x4b, 0x6c, 0xc2, 0xc7, 0x93, 0x16, 0x33, 0x7f, 0xc1, 0x9d, 0x3f, 0xcb, 0xe5, 0x2c, 0x5d, + 0x1a, 0xf8, 0x23, 0xa6, 0xaf, 0xb7, 0xa5, 0x1f, 0x4c, 0xcc, 0x64, 0x36, 0xf0, 0xee, 0x79, 0xf7, + 0x9c, 0x7b, 0x4b, 0xcf, 0x01, 0xcf, 0x5c, 0xe5, 0x0f, 0x5c, 0xe5, 0xab, 0xe5, 0x22, 0x5c, 0x0c, + 0xf4, 0x67, 0x10, 0xd5, 0xa7, 0xfa, 0x48, 0x35, 0x57, 0xf9, 0xa2, 0x0d, 0xba, 0x5c, 0x4a, 0x37, + 0x94, 0x9f, 0x94, 0x7b, 0x2d, 0x27, 0xf2, 0xfb, 0x4a, 0x06, 0xa1, 0x78, 0x81, 0xe3, 0x1c, 0x1a, + 0xa8, 0xc5, 0x3c, 0x90, 0xd4, 0x44, 0xd5, 0xf7, 0x2c, 0xa3, 0x67, 0xf4, 0xcd, 0x49, 0xd5, 0xf7, + 0x22, 0xf2, 0x48, 0x2e, 0xfd, 0x1f, 0x25, 0x72, 0x0e, 0xbd, 0x83, 0xfc, 0x1a, 0x9d, 0x78, 0xc6, + 0x68, 0x71, 0xbd, 0x9a, 0xc9, 0x79, 0xc8, 0x7c, 0xb2, 0x70, 0x10, 0x44, 0xcc, 0x71, 0xd2, 0x9d, + 0x94, 0xa2, 0x8f, 0x6e, 0x91, 0x72, 0x87, 0xf8, 0x47, 0x74, 0x46, 0x72, 0x2a, 0xef, 0x21, 0x4e, + 0x0e, 0xe0, 0x71, 0xf3, 0xd8, 0xb3, 0xaa, 0xfa, 0x32, 0x83, 0x08, 0x0b, 0xdd, 0xa2, 0x64, 0x3c, + 0x5c, 0x7c, 0x41, 0x73, 0xe8, 0x79, 0x57, 0xf2, 0xe6, 0xe1, 0x53, 0x88, 0x50, 0x0f, 0xe5, 0x4d, + 0x68, 0xd5, 0xf4, 0x8d, 0x3e, 0x8b, 0x31, 0x5a, 0xa9, 0x3e, 0x3f, 0x6f, 0x5e, 0xc6, 0x28, 0xc9, + 0x74, 0xb1, 0xff, 0x4d, 0xba, 0x5e, 0x3a, 0x82, 0x2b, 0xf1, 0x01, 0xad, 0xd1, 0x6a, 0xa6, 0xae, + 0x96, 0x52, 0x3e, 0xfc, 0x17, 0x39, 0xc1, 0xd1, 0x56, 0x8c, 0x17, 0x23, 0xd4, 0xbd, 0xd5, 0x4c, + 0xb1, 0x94, 0x3e, 0x8b, 0x97, 0x68, 0x0d, 0xa7, 0xd3, 0xa8, 0x2d, 0xf8, 0xff, 0x3b, 0x7e, 0x85, + 0x7a, 0xd4, 0x59, 0x7c, 0xa3, 0xd4, 0xc6, 0x5e, 0xf4, 0x0c, 0x81, 0x55, 0xed, 0xd5, 0xfa, 0xe6, + 0x24, 0x2e, 0xc4, 0x39, 0x8e, 0xb6, 0xd2, 0xbc, 0xc2, 0x73, 0xec, 0x85, 0x11, 0x60, 0x19, 0xbd, + 0x5a, 0xbf, 0x71, 0x66, 0x9e, 0x46, 0x96, 0xd7, 0x4b, 0xc6, 0xb8, 0x20, 0x4d, 0xd2, 0xee, 0x4c, + 0x16, 0x12, 0x03, 0x3c, 0xce, 0x60, 0xac, 0x64, 0xe3, 0x90, 0xd7, 0x8a, 0xc5, 0xcc, 0x49, 0x5a, + 0x9f, 0xfd, 0xac, 0xc3, 0xbc, 0x9c, 0xfa, 0x72, 0x1e, 0x0e, 0x95, 0x4f, 0x17, 0x68, 0x64, 0x02, + 0x43, 0x4f, 0xf4, 0xcc, 0x72, 0xb0, 0x6c, 0xab, 0x7c, 0xc1, 0xb3, 0x2e, 0xd0, 0xc8, 0xa4, 0x86, + 0x15, 0xca, 0xe9, 0x62, 0x85, 0x5d, 0x01, 0x1b, 0xa3, 0x99, 0x4f, 0x07, 0xd9, 0x99, 0x69, 0x85, + 0x20, 0xd8, 0x4f, 0x77, 0xde, 0x6d, 0xa5, 0xf2, 0x5e, 0x67, 0xa9, 0x9d, 0x99, 0x62, 0xa9, 0xdd, + 0xe1, 0xa0, 0x37, 0x38, 0x60, 0xf3, 0xd2, 0xb1, 0xee, 0xcb, 0x47, 0xc5, 0x6e, 0xe7, 0x41, 0x66, + 0xbd, 0xc5, 0x61, 0x62, 0x2d, 0x8a, 0x3b, 0x0a, 0xb6, 0xb5, 0x3b, 0x05, 0x74, 0x4b, 0x4c, 0x0c, + 0xc1, 0xc4, 0x82, 0xf5, 0x98, 0x58, 0x72, 0xcd, 0x3b, 0x98, 0xa9, 0x01, 0x28, 0xed, 0xc9, 0x99, + 0xc4, 0xee, 0x16, 0xe1, 0x98, 0xfb, 0xfe, 0xe4, 0xf7, 0xda, 0x31, 0x6e, 0xd7, 0x8e, 0xf1, 0x77, + 0xed, 0x18, 0xbf, 0x36, 0x4e, 0xe5, 0x76, 0xe3, 0x54, 0xfe, 0x6c, 0x9c, 0xca, 0xe7, 0x47, 0xd9, + 0xbf, 0xe0, 0xaf, 0xfb, 0xfa, 0xeb, 0xfc, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x38, 0x60, 0xfe, + 0x5b, 0x99, 0x05, 0x00, 0x00, +} + +func (m *CreateSpaceRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CreateSpaceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CreateSpaceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *CreateSpaceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CreateSpaceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CreateSpaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintApi(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeriveSpaceRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeriveSpaceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeriveSpaceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *DeriveSpaceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeriveSpaceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeriveSpaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintApi(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CreateDocumentRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CreateDocumentRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CreateDocumentRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintApi(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CreateDocumentResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CreateDocumentResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CreateDocumentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintApi(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeleteDocumentRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeleteDocumentRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteDocumentRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DocumentId) > 0 { + i -= len(m.DocumentId) + copy(dAtA[i:], m.DocumentId) + i = encodeVarintApi(dAtA, i, uint64(len(m.DocumentId))) + i-- + dAtA[i] = 0x12 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintApi(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DeleteDocumentResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DeleteDocumentResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DeleteDocumentResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *AddTextRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AddTextRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddTextRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Text) > 0 { + i -= len(m.Text) + copy(dAtA[i:], m.Text) + i = encodeVarintApi(dAtA, i, uint64(len(m.Text))) + i-- + dAtA[i] = 0x1a + } + if len(m.DocumentId) > 0 { + i -= len(m.DocumentId) + copy(dAtA[i:], m.DocumentId) + i = encodeVarintApi(dAtA, i, uint64(len(m.DocumentId))) + i-- + dAtA[i] = 0x12 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintApi(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AddTextResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AddTextResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AddTextResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.HeadId) > 0 { + i -= len(m.HeadId) + copy(dAtA[i:], m.HeadId) + i = encodeVarintApi(dAtA, i, uint64(len(m.HeadId))) + i-- + dAtA[i] = 0x12 + } + if len(m.DocumentId) > 0 { + i -= len(m.DocumentId) + copy(dAtA[i:], m.DocumentId) + i = encodeVarintApi(dAtA, i, uint64(len(m.DocumentId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DumpTreeRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DumpTreeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DumpTreeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DocumentId) > 0 { + i -= len(m.DocumentId) + copy(dAtA[i:], m.DocumentId) + i = encodeVarintApi(dAtA, i, uint64(len(m.DocumentId))) + i-- + dAtA[i] = 0x12 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintApi(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DumpTreeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DumpTreeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DumpTreeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Dump) > 0 { + i -= len(m.Dump) + copy(dAtA[i:], m.Dump) + i = encodeVarintApi(dAtA, i, uint64(len(m.Dump))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AllTreesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AllTreesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllTreesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintApi(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Tree) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Tree) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Tree) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Heads) > 0 { + for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Heads[iNdEx]) + copy(dAtA[i:], m.Heads[iNdEx]) + i = encodeVarintApi(dAtA, i, uint64(len(m.Heads[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintApi(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AllTreesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AllTreesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllTreesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Trees) > 0 { + for iNdEx := len(m.Trees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Trees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintApi(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *AllSpacesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AllSpacesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllSpacesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *AllSpacesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AllSpacesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AllSpacesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SpaceIds) > 0 { + for iNdEx := len(m.SpaceIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SpaceIds[iNdEx]) + copy(dAtA[i:], m.SpaceIds[iNdEx]) + i = encodeVarintApi(dAtA, i, uint64(len(m.SpaceIds[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintApi(dAtA []byte, offset int, v uint64) int { + offset -= sovApi(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *CreateSpaceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *CreateSpaceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *DeriveSpaceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *DeriveSpaceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *CreateDocumentRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *CreateDocumentResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *DeleteDocumentRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + l = len(m.DocumentId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *DeleteDocumentResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *AddTextRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + l = len(m.DocumentId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + l = len(m.Text) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *AddTextResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DocumentId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + l = len(m.HeadId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *DumpTreeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + l = len(m.DocumentId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *DumpTreeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Dump) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *AllTreesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + return n +} + +func (m *Tree) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovApi(uint64(l)) + } + if len(m.Heads) > 0 { + for _, s := range m.Heads { + l = len(s) + n += 1 + l + sovApi(uint64(l)) + } + } + return n +} + +func (m *AllTreesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Trees) > 0 { + for _, e := range m.Trees { + l = e.Size() + n += 1 + l + sovApi(uint64(l)) + } + } + return n +} + +func (m *AllSpacesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *AllSpacesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.SpaceIds) > 0 { + for _, s := range m.SpaceIds { + l = len(s) + n += 1 + l + sovApi(uint64(l)) + } + } + return n +} + +func sovApi(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozApi(x uint64) (n int) { + return sovApi(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *CreateSpaceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CreateSpaceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateSpaceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CreateSpaceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CreateSpaceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateSpaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeriveSpaceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeriveSpaceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeriveSpaceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeriveSpaceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeriveSpaceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeriveSpaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CreateDocumentRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CreateDocumentRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateDocumentRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CreateDocumentResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CreateDocumentResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CreateDocumentResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteDocumentRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteDocumentRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteDocumentRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DocumentId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DocumentId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DeleteDocumentResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DeleteDocumentResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DeleteDocumentResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AddTextRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AddTextRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddTextRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DocumentId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DocumentId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Text = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AddTextResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AddTextResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddTextResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DocumentId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DocumentId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeadId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HeadId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DumpTreeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DumpTreeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DumpTreeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DocumentId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DocumentId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DumpTreeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DumpTreeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DumpTreeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dump", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Dump = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllTreesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AllTreesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllTreesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Tree) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Tree: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Tree: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Heads", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllTreesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AllTreesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllTreesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Trees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Trees = append(m.Trees, &Tree{}) + if err := m.Trees[len(m.Trees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllSpacesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AllSpacesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllSpacesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AllSpacesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AllSpacesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AllSpacesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthApi + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceIds = append(m.SpaceIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipApi(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowApi + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowApi + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowApi + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthApi + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupApi + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthApi + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthApi = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowApi = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupApi = fmt.Errorf("proto: unexpected end of group") +) diff --git a/client/api/apiproto/api_drpc.pb.go b/client/api/apiproto/api_drpc.pb.go new file mode 100644 index 00000000..089dd379 --- /dev/null +++ b/client/api/apiproto/api_drpc.pb.go @@ -0,0 +1,393 @@ +// Code generated by protoc-gen-go-drpc. DO NOT EDIT. +// protoc-gen-go-drpc version: v0.0.32 +// source: api/apiproto/protos/api.proto + +package apiproto + +import ( + bytes "bytes" + context "context" + errors "errors" + jsonpb "github.com/gogo/protobuf/jsonpb" + proto "github.com/gogo/protobuf/proto" + drpc "storj.io/drpc" + drpcerr "storj.io/drpc/drpcerr" +) + +type drpcEncoding_File_api_apiproto_protos_api_proto struct{} + +func (drpcEncoding_File_api_apiproto_protos_api_proto) Marshal(msg drpc.Message) ([]byte, error) { + return proto.Marshal(msg.(proto.Message)) +} + +func (drpcEncoding_File_api_apiproto_protos_api_proto) Unmarshal(buf []byte, msg drpc.Message) error { + return proto.Unmarshal(buf, msg.(proto.Message)) +} + +func (drpcEncoding_File_api_apiproto_protos_api_proto) JSONMarshal(msg drpc.Message) ([]byte, error) { + var buf bytes.Buffer + err := new(jsonpb.Marshaler).Marshal(&buf, msg.(proto.Message)) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func (drpcEncoding_File_api_apiproto_protos_api_proto) JSONUnmarshal(buf []byte, msg drpc.Message) error { + return jsonpb.Unmarshal(bytes.NewReader(buf), msg.(proto.Message)) +} + +type DRPCClientApiClient interface { + DRPCConn() drpc.Conn + + CreateSpace(ctx context.Context, in *CreateSpaceRequest) (*CreateSpaceResponse, error) + DeriveSpace(ctx context.Context, in *DeriveSpaceRequest) (*DeriveSpaceResponse, error) + CreateDocument(ctx context.Context, in *CreateDocumentRequest) (*CreateDocumentResponse, error) + DeleteDocument(ctx context.Context, in *DeleteDocumentRequest) (*DeleteDocumentResponse, error) + AddText(ctx context.Context, in *AddTextRequest) (*AddTextResponse, error) + DumpTree(ctx context.Context, in *DumpTreeRequest) (*DumpTreeResponse, error) + AllTrees(ctx context.Context, in *AllTreesRequest) (*AllTreesResponse, error) + AllSpaces(ctx context.Context, in *AllSpacesRequest) (*AllSpacesResponse, error) +} + +type drpcClientApiClient struct { + cc drpc.Conn +} + +func NewDRPCClientApiClient(cc drpc.Conn) DRPCClientApiClient { + return &drpcClientApiClient{cc} +} + +func (c *drpcClientApiClient) DRPCConn() drpc.Conn { return c.cc } + +func (c *drpcClientApiClient) CreateSpace(ctx context.Context, in *CreateSpaceRequest) (*CreateSpaceResponse, error) { + out := new(CreateSpaceResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/CreateSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcClientApiClient) DeriveSpace(ctx context.Context, in *DeriveSpaceRequest) (*DeriveSpaceResponse, error) { + out := new(DeriveSpaceResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/DeriveSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcClientApiClient) CreateDocument(ctx context.Context, in *CreateDocumentRequest) (*CreateDocumentResponse, error) { + out := new(CreateDocumentResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/CreateDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcClientApiClient) DeleteDocument(ctx context.Context, in *DeleteDocumentRequest) (*DeleteDocumentResponse, error) { + out := new(DeleteDocumentResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/DeleteDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcClientApiClient) AddText(ctx context.Context, in *AddTextRequest) (*AddTextResponse, error) { + out := new(AddTextResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/AddText", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcClientApiClient) DumpTree(ctx context.Context, in *DumpTreeRequest) (*DumpTreeResponse, error) { + out := new(DumpTreeResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcClientApiClient) AllTrees(ctx context.Context, in *AllTreesRequest) (*AllTreesResponse, error) { + out := new(AllTreesResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcClientApiClient) AllSpaces(ctx context.Context, in *AllSpacesRequest) (*AllSpacesResponse, error) { + out := new(AllSpacesResponse) + err := c.cc.Invoke(ctx, "/api.ClientApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +type DRPCClientApiServer interface { + CreateSpace(context.Context, *CreateSpaceRequest) (*CreateSpaceResponse, error) + DeriveSpace(context.Context, *DeriveSpaceRequest) (*DeriveSpaceResponse, error) + CreateDocument(context.Context, *CreateDocumentRequest) (*CreateDocumentResponse, error) + DeleteDocument(context.Context, *DeleteDocumentRequest) (*DeleteDocumentResponse, error) + AddText(context.Context, *AddTextRequest) (*AddTextResponse, error) + DumpTree(context.Context, *DumpTreeRequest) (*DumpTreeResponse, error) + AllTrees(context.Context, *AllTreesRequest) (*AllTreesResponse, error) + AllSpaces(context.Context, *AllSpacesRequest) (*AllSpacesResponse, error) +} + +type DRPCClientApiUnimplementedServer struct{} + +func (s *DRPCClientApiUnimplementedServer) CreateSpace(context.Context, *CreateSpaceRequest) (*CreateSpaceResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCClientApiUnimplementedServer) DeriveSpace(context.Context, *DeriveSpaceRequest) (*DeriveSpaceResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCClientApiUnimplementedServer) CreateDocument(context.Context, *CreateDocumentRequest) (*CreateDocumentResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCClientApiUnimplementedServer) DeleteDocument(context.Context, *DeleteDocumentRequest) (*DeleteDocumentResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCClientApiUnimplementedServer) AddText(context.Context, *AddTextRequest) (*AddTextResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCClientApiUnimplementedServer) DumpTree(context.Context, *DumpTreeRequest) (*DumpTreeResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCClientApiUnimplementedServer) AllTrees(context.Context, *AllTreesRequest) (*AllTreesResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCClientApiUnimplementedServer) AllSpaces(context.Context, *AllSpacesRequest) (*AllSpacesResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +type DRPCClientApiDescription struct{} + +func (DRPCClientApiDescription) NumMethods() int { return 8 } + +func (DRPCClientApiDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) { + switch n { + case 0: + return "/api.ClientApi/CreateSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + CreateSpace( + ctx, + in1.(*CreateSpaceRequest), + ) + }, DRPCClientApiServer.CreateSpace, true + case 1: + return "/api.ClientApi/DeriveSpace", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + DeriveSpace( + ctx, + in1.(*DeriveSpaceRequest), + ) + }, DRPCClientApiServer.DeriveSpace, true + case 2: + return "/api.ClientApi/CreateDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + CreateDocument( + ctx, + in1.(*CreateDocumentRequest), + ) + }, DRPCClientApiServer.CreateDocument, true + case 3: + return "/api.ClientApi/DeleteDocument", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + DeleteDocument( + ctx, + in1.(*DeleteDocumentRequest), + ) + }, DRPCClientApiServer.DeleteDocument, true + case 4: + return "/api.ClientApi/AddText", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + AddText( + ctx, + in1.(*AddTextRequest), + ) + }, DRPCClientApiServer.AddText, true + case 5: + return "/api.ClientApi/DumpTree", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + DumpTree( + ctx, + in1.(*DumpTreeRequest), + ) + }, DRPCClientApiServer.DumpTree, true + case 6: + return "/api.ClientApi/AllTrees", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + AllTrees( + ctx, + in1.(*AllTreesRequest), + ) + }, DRPCClientApiServer.AllTrees, true + case 7: + return "/api.ClientApi/AllSpaces", drpcEncoding_File_api_apiproto_protos_api_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCClientApiServer). + AllSpaces( + ctx, + in1.(*AllSpacesRequest), + ) + }, DRPCClientApiServer.AllSpaces, true + default: + return "", nil, nil, nil, false + } +} + +func DRPCRegisterClientApi(mux drpc.Mux, impl DRPCClientApiServer) error { + return mux.Register(impl, DRPCClientApiDescription{}) +} + +type DRPCClientApi_CreateSpaceStream interface { + drpc.Stream + SendAndClose(*CreateSpaceResponse) error +} + +type drpcClientApi_CreateSpaceStream struct { + drpc.Stream +} + +func (x *drpcClientApi_CreateSpaceStream) SendAndClose(m *CreateSpaceResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCClientApi_DeriveSpaceStream interface { + drpc.Stream + SendAndClose(*DeriveSpaceResponse) error +} + +type drpcClientApi_DeriveSpaceStream struct { + drpc.Stream +} + +func (x *drpcClientApi_DeriveSpaceStream) SendAndClose(m *DeriveSpaceResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCClientApi_CreateDocumentStream interface { + drpc.Stream + SendAndClose(*CreateDocumentResponse) error +} + +type drpcClientApi_CreateDocumentStream struct { + drpc.Stream +} + +func (x *drpcClientApi_CreateDocumentStream) SendAndClose(m *CreateDocumentResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCClientApi_DeleteDocumentStream interface { + drpc.Stream + SendAndClose(*DeleteDocumentResponse) error +} + +type drpcClientApi_DeleteDocumentStream struct { + drpc.Stream +} + +func (x *drpcClientApi_DeleteDocumentStream) SendAndClose(m *DeleteDocumentResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCClientApi_AddTextStream interface { + drpc.Stream + SendAndClose(*AddTextResponse) error +} + +type drpcClientApi_AddTextStream struct { + drpc.Stream +} + +func (x *drpcClientApi_AddTextStream) SendAndClose(m *AddTextResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCClientApi_DumpTreeStream interface { + drpc.Stream + SendAndClose(*DumpTreeResponse) error +} + +type drpcClientApi_DumpTreeStream struct { + drpc.Stream +} + +func (x *drpcClientApi_DumpTreeStream) SendAndClose(m *DumpTreeResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCClientApi_AllTreesStream interface { + drpc.Stream + SendAndClose(*AllTreesResponse) error +} + +type drpcClientApi_AllTreesStream struct { + drpc.Stream +} + +func (x *drpcClientApi_AllTreesStream) SendAndClose(m *AllTreesResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCClientApi_AllSpacesStream interface { + drpc.Stream + SendAndClose(*AllSpacesResponse) error +} + +type drpcClientApi_AllSpacesStream struct { + drpc.Stream +} + +func (x *drpcClientApi_AllSpacesStream) SendAndClose(m *AllSpacesResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_api_apiproto_protos_api_proto{}); err != nil { + return err + } + return x.CloseSend() +} diff --git a/client/api/apiproto/protos/api.proto b/client/api/apiproto/protos/api.proto new file mode 100644 index 00000000..4ac23157 --- /dev/null +++ b/client/api/apiproto/protos/api.proto @@ -0,0 +1,85 @@ +syntax = "proto3"; +package api; + +option go_package = "api/apiproto"; + +service ClientApi { + rpc CreateSpace(CreateSpaceRequest) returns(CreateSpaceResponse); + rpc DeriveSpace(DeriveSpaceRequest) returns(DeriveSpaceResponse); + rpc CreateDocument(CreateDocumentRequest) returns(CreateDocumentResponse); + rpc DeleteDocument(DeleteDocumentRequest) returns(DeleteDocumentResponse); + rpc AddText(AddTextRequest) returns(AddTextResponse); + rpc DumpTree(DumpTreeRequest) returns(DumpTreeResponse); + rpc AllTrees(AllTreesRequest) returns(AllTreesResponse); + rpc AllSpaces(AllSpacesRequest) returns(AllSpacesResponse); +} + +message CreateSpaceRequest { +} + +message CreateSpaceResponse { + string id = 1; +} + +message DeriveSpaceRequest { +} + +message DeriveSpaceResponse { + string id = 1; +} + +message CreateDocumentRequest { + string spaceId = 1; +} + +message CreateDocumentResponse { + string id = 1; +} + +message DeleteDocumentRequest { + string spaceId = 1; + string documentId = 2; +} + +message DeleteDocumentResponse { +} + +message AddTextRequest { + string spaceId = 1; + string documentId = 2; + string text = 3; +} + +message AddTextResponse { + string documentId = 1; + string headId = 2; +} + +message DumpTreeRequest { + string spaceId = 1; + string documentId = 2; +} + +message DumpTreeResponse { + string dump = 1; +} + +message AllTreesRequest { + string spaceId = 1; +} + +message Tree { + string id = 1; + repeated string heads = 2; +} + +message AllTreesResponse { + repeated Tree trees = 1; +} + +message AllSpacesRequest { +} + +message AllSpacesResponse { + repeated string spaceIds = 1; +} \ No newline at end of file diff --git a/common/Makefile b/common/Makefile index b8ca99a8..8661453c 100644 --- a/common/Makefile +++ b/common/Makefile @@ -3,7 +3,7 @@ export GOPRIVATE=github.com/anytypeio proto: @echo 'Generating protobuf packages (Go)...' -# Uncomment if needed + @$(eval GOGO_START := GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1) @$(eval P_ACL_RECORDS_PATH_PB := pkg/acl/aclrecordproto) @$(eval P_TREE_CHANGES_PATH_PB := pkg/acl/treechangeproto) diff --git a/common/net/rpc/server/baseserver.go b/common/net/rpc/server/baseserver.go new file mode 100644 index 00000000..6230d63b --- /dev/null +++ b/common/net/rpc/server/baseserver.go @@ -0,0 +1,105 @@ +package server + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure" + "github.com/zeebo/errs" + "go.uber.org/zap" + "io" + "net" + "storj.io/drpc" + "storj.io/drpc/drpcmux" + "storj.io/drpc/drpcserver" + "time" +) + +type BaseDrpcServer struct { + drpcServer *drpcserver.Server + transport secure.Service + listeners []secure.ContextListener + cancel func() + *drpcmux.Mux +} + +type DRPCHandlerWrapper func(handler drpc.Handler) drpc.Handler + +func NewBaseDrpcServer() *BaseDrpcServer { + return &BaseDrpcServer{Mux: drpcmux.New()} +} + +func (s *BaseDrpcServer) Init(transport secure.Service) { + s.transport = transport +} + +func (s *BaseDrpcServer) Run(ctx context.Context, listenAddrs []string, wrapper DRPCHandlerWrapper) (err error) { + s.drpcServer = drpcserver.New(wrapper(s.Mux)) + ctx, s.cancel = context.WithCancel(ctx) + for _, addr := range listenAddrs { + tcpList, err := net.Listen("tcp", addr) + if err != nil { + return err + } + tlsList := s.transport.TLSListener(tcpList) + go s.serve(ctx, tlsList) + } + return +} + +func (s *BaseDrpcServer) serve(ctx context.Context, lis secure.ContextListener) { + l := log.With(zap.String("localAddr", lis.Addr().String())) + l.Info("drpc listener started") + defer func() { + l.Debug("drpc listener stopped") + }() + for { + select { + case <-ctx.Done(): + return + default: + } + ctx, conn, err := lis.Accept(ctx) + if err != nil { + if isTemporary(err) { + l.Debug("listener temporary accept error", zap.Error(err)) + t := time.NewTimer(500 * time.Millisecond) + select { + case <-t.C: + case <-ctx.Done(): + return + } + continue + } + if _, ok := err.(secure.HandshakeError); ok { + l.Warn("listener handshake error", zap.Error(err)) + continue + } + l.Error("listener accept error", zap.Error(err)) + return + } + go s.serveConn(ctx, conn) + } +} + +func (s *BaseDrpcServer) serveConn(ctx context.Context, conn net.Conn) { + l := log.With(zap.String("remoteAddr", conn.RemoteAddr().String())).With(zap.String("localAddr", conn.LocalAddr().String())) + l.Debug("connection opened") + if err := s.drpcServer.ServeOne(ctx, conn); err != nil { + if errs.Is(err, context.Canceled) || errs.Is(err, io.EOF) { + l.Debug("connection closed") + } else { + l.Warn("serve connection error", zap.Error(err)) + } + } +} + +func (s *BaseDrpcServer) Close(ctx context.Context) (err error) { + if s.cancel != nil { + s.cancel() + } + for _, l := range s.listeners { + if e := l.Close(); e != nil { + log.Warn("close listener error", zap.Error(e)) + } + } + return +} diff --git a/common/net/rpc/server/drpcserver.go b/common/net/rpc/server/drpcserver.go index 3d1341b6..ce20bbd6 100644 --- a/common/net/rpc/server/drpcserver.go +++ b/common/net/rpc/server/drpcserver.go @@ -8,14 +8,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/metric" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure" "github.com/prometheus/client_golang/prometheus" - "github.com/zeebo/errs" - "go.uber.org/zap" - "io" - "net" "storj.io/drpc" - "storj.io/drpc/drpcmux" - "storj.io/drpc/drpcserver" - "time" ) const CName = "common.net.drpcserver" @@ -23,7 +16,7 @@ const CName = "common.net.drpcserver" var log = logger.NewNamed(CName) func New() DRPCServer { - return &drpcServer{Mux: drpcmux.New()} + return &drpcServer{BaseDrpcServer: NewBaseDrpcServer()} } type DRPCServer interface { @@ -36,19 +29,15 @@ type configGetter interface { } type drpcServer struct { - config config.GrpcServer - drpcServer *drpcserver.Server - transport secure.Service - listeners []secure.ContextListener - metric metric.Metric - cancel func() - *drpcmux.Mux + config config.GrpcServer + metric metric.Metric + *BaseDrpcServer } func (s *drpcServer) Init(a *app.App) (err error) { s.config = a.MustComponent(config.CName).(configGetter).GetGRPCServer() - s.transport = a.MustComponent(secure.CName).(secure.Service) s.metric = a.MustComponent(metric.CName).(metric.Metric) + s.BaseDrpcServer.Init(a.MustComponent(secure.CName).(secure.Service)) return nil } @@ -68,80 +57,17 @@ func (s *drpcServer) Run(ctx context.Context) (err error) { 0.99: 0.0001, }, }, []string{"rpc"}) - s.drpcServer = drpcserver.New(&metric.PrometheusDRPC{ - Handler: s.Mux, - SummaryVec: histVec, - }) if err = s.metric.Registry().Register(histVec); err != nil { return } - ctx, s.cancel = context.WithCancel(ctx) - for _, addr := range s.config.ListenAddrs { - tcpList, err := net.Listen("tcp", addr) - if err != nil { - return err + return s.BaseDrpcServer.Run(ctx, s.config.ListenAddrs, func(handler drpc.Handler) drpc.Handler { + return &metric.PrometheusDRPC{ + Handler: handler, + SummaryVec: histVec, } - tlsList := s.transport.TLSListener(tcpList) - go s.serve(ctx, tlsList) - } - return -} - -func (s *drpcServer) serve(ctx context.Context, lis secure.ContextListener) { - l := log.With(zap.String("localAddr", lis.Addr().String())) - l.Info("drpc listener started") - defer func() { - l.Debug("drpc listener stopped") - }() - for { - select { - case <-ctx.Done(): - return - default: - } - ctx, conn, err := lis.Accept(ctx) - if err != nil { - if isTemporary(err) { - l.Debug("listener temporary accept error", zap.Error(err)) - t := time.NewTimer(500 * time.Millisecond) - select { - case <-t.C: - case <-ctx.Done(): - return - } - continue - } - if _, ok := err.(secure.HandshakeError); ok { - l.Warn("listener handshake error", zap.Error(err)) - continue - } - l.Error("listener accept error", zap.Error(err)) - return - } - go s.serveConn(ctx, conn) - } -} - -func (s *drpcServer) serveConn(ctx context.Context, conn net.Conn) { - l := log.With(zap.String("remoteAddr", conn.RemoteAddr().String())).With(zap.String("localAddr", conn.LocalAddr().String())) - l.Debug("connection opened") - if err := s.drpcServer.ServeOne(ctx, conn); err != nil { - if errs.Is(err, context.Canceled) || errs.Is(err, io.EOF) { - l.Debug("connection closed") - } else { - l.Warn("serve connection error", zap.Error(err)) - } - } + }) } func (s *drpcServer) Close(ctx context.Context) (err error) { - if s.cancel != nil { - s.cancel() - } - for _, l := range s.listeners { - if e := l.Close(); e != nil { - log.Warn("close listener error", zap.Error(e)) - } - } - return + return s.BaseDrpcServer.Close(ctx) }