migrate from model to store

This commit is contained in:
Asim Aslam
2021-12-10 20:37:14 +00:00
parent c28d9a8cc4
commit 50e3377f32
3 changed files with 150 additions and 318 deletions

View File

@@ -8,29 +8,34 @@ import (
"github.com/micro/micro/v3/service/errors"
log "github.com/micro/micro/v3/service/logger"
"github.com/micro/micro/v3/service/model"
"github.com/micro/micro/v3/service/store"
file "github.com/micro/services/file/proto"
"github.com/micro/services/pkg/tenant"
)
type File struct {
db model.Model
}
type File struct{}
func NewFile() *File {
i := model.ByEquality("project")
i.Order.Type = model.OrderTypeUnordered
f := &File{}
go f.Migrate()
return f
}
db := model.New(
file.Record{},
&model.Options{
Key: "Path",
Indexes: []model.Index{i},
},
)
func (e *File) Migrate() {
records, err := store.Read("file.Record:eqByProjectUnordByProject:", store.ReadPrefix())
if err != nil {
log.Errorf("failed to migrate: %v", err)
return
}
return &File{
db: db,
for _, rec := range records {
parts := strings.Split(rec.Key, ":")
if len(parts) != 4 {
continue
}
key := "file/" + parts[3]
log.Infof("Migrating %v to %v\n", rec.Key, key)
store.Write(&store.Record{Key: key, Value: rec.Value})
}
}
@@ -44,32 +49,21 @@ func (e *File) Delete(ctx context.Context, req *file.DeleteRequest, rsp *file.De
tenantId = "micro"
}
path := filepath.Join(tenantId, req.Project, req.Path)
project := tenantId + "/" + req.Project
path := filepath.Join("file", tenantId, req.Project, req.Path)
// delete one file
if !strings.HasSuffix(req.Path, "/") {
return e.db.Delete(model.QueryEquals("Path", path))
return store.Delete(path)
}
var files []*file.Record
// read all the files for the project
err := e.db.Read(model.QueryEquals("project", project), &files)
records, err := store.List(store.ListPrefix(path))
if err != nil {
return err
}
for _, file := range files {
// delete a list of files
if file.Project != project {
continue
}
if !strings.HasPrefix(file.Path, path) {
continue
}
// delete the file
e.db.Delete(model.QueryEquals("Path", file.Path))
for _, file := range records {
store.Delete(file)
}
return nil
@@ -87,31 +81,30 @@ func (e *File) Read(ctx context.Context, req *file.ReadRequest, rsp *file.ReadRe
tenantId = "micro"
}
var files []*file.Record
path := filepath.Join("file", tenantId, req.Project, req.Path)
project := tenantId + "/" + req.Project
var opts []store.ReadOption
// read all the files for the project
err := e.db.Read(model.QueryEquals("project", project), &files)
if strings.HasSuffix(req.Path, "/") {
opts = append(opts, store.ReadPrefix())
}
records, err := store.Read(path, opts...)
if err != nil {
return err
}
// filter the file
for _, file := range files {
// check project matches tenants
if file.Project != project {
for _, rec := range records {
file := new(file.Record)
if err := rec.Decode(file); err != nil {
continue
}
// strip the tenant id
file.Project = strings.TrimPrefix(file.Project, tenantId+"/")
file.Path = strings.TrimPrefix(file.Path, filepath.Join(tenantId, req.Project))
// check the path matches the request
if req.Path == file.Path {
rsp.File = file
}
}
return nil
@@ -123,11 +116,13 @@ func (e *File) Save(ctx context.Context, req *file.SaveRequest, rsp *file.SaveRe
tenantId = "micro"
}
if req.File == nil {
return errors.BadRequest("file.save", "missing file")
}
log.Info("Received File.Save request")
// prefix the tenant
req.File.Project = filepath.Join(tenantId, req.File.Project)
req.File.Path = filepath.Join(req.File.Project, req.File.Path)
path := filepath.Join("file", tenantId, req.File.Project, req.File.Path)
if len(req.File.Created) == 0 {
req.File.Created = time.Now().Format(time.RFC3339Nano)
@@ -137,35 +132,7 @@ func (e *File) Save(ctx context.Context, req *file.SaveRequest, rsp *file.SaveRe
req.File.Updated = time.Now().Format(time.RFC3339Nano)
// create the file
err := e.db.Create(req.File)
if err != nil {
return err
}
return nil
}
func (e *File) BatchSave(ctx context.Context, req *file.BatchSaveRequest, rsp *file.BatchSaveResponse) error {
tenantId, ok := tenant.FromContext(ctx)
if !ok {
tenantId = "micro"
}
log.Info("Received File.BatchSave request")
for _, reqFile := range req.Files {
// prefix the tenant
reqFile.Project = filepath.Join(tenantId, reqFile.Project)
reqFile.Path = filepath.Join(reqFile.Project, reqFile.Project)
// create the file
err := e.db.Create(reqFile)
if err != nil {
return err
}
}
return nil
return store.Write(store.NewRecord(path, req.File))
}
func (e *File) List(ctx context.Context, req *file.ListRequest, rsp *file.ListResponse) error {
@@ -177,20 +144,17 @@ func (e *File) List(ctx context.Context, req *file.ListRequest, rsp *file.ListRe
}
// prefix tenant id
project := tenantId + "/" + req.Project
path := filepath.Join("file", tenantId, req.Project, req.Path)
var files []*file.Record
// read all the files for the project
if err := e.db.Read(model.QueryEquals("project", project), &files); err != nil {
records, err := store.Read(path, store.ReadPrefix())
if err != nil {
return err
}
// @todo funnily while this is the archetypical
// query for the KV store interface, it's not supported by the model
// so we do client side filtering here
for _, file := range files {
if file.Project != project {
for _, rec := range records {
file := new(file.Record)
if err := rec.Decode(file); err != nil {
continue
}
@@ -202,14 +166,7 @@ func (e *File) List(ctx context.Context, req *file.ListRequest, rsp *file.ListRe
// no file listing ever contains it
file.Content = ""
// if requesting all files or path matches
if req.Path != "" {
if strings.HasPrefix(file.Path, req.Path) {
rsp.Files = append(rsp.Files, file)
}
} else {
rsp.Files = append(rsp.Files, file)
}
rsp.Files = append(rsp.Files, file)
}
return nil

View File

@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc-gen-go v1.27.1
// protoc v3.15.6
// source: proto/file.proto
@@ -36,7 +36,7 @@ type Record struct {
Created string `protobuf:"bytes,4,opt,name=created,proto3" json:"created,omitempty"`
// Time the file was updated e.g 2021-05-20T13:37:21Z
Updated string `protobuf:"bytes,5,opt,name=updated,proto3" json:"updated,omitempty"`
// Any other associated metadata
// Any other associated metadata as a map of key-value pairs
Metadata map[string]string `protobuf:"bytes,6,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
@@ -114,92 +114,6 @@ func (x *Record) GetMetadata() map[string]string {
return nil
}
// Batch save multiple files in one call
type BatchSaveRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Files []*Record `protobuf:"bytes,1,rep,name=files,proto3" json:"files,omitempty"`
}
func (x *BatchSaveRequest) Reset() {
*x = BatchSaveRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BatchSaveRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BatchSaveRequest) ProtoMessage() {}
func (x *BatchSaveRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BatchSaveRequest.ProtoReflect.Descriptor instead.
func (*BatchSaveRequest) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{1}
}
func (x *BatchSaveRequest) GetFiles() []*Record {
if x != nil {
return x.Files
}
return nil
}
type BatchSaveResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *BatchSaveResponse) Reset() {
*x = BatchSaveResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BatchSaveResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BatchSaveResponse) ProtoMessage() {}
func (x *BatchSaveResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BatchSaveResponse.ProtoReflect.Descriptor instead.
func (*BatchSaveResponse) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{2}
}
// Read a file by path
type ReadRequest struct {
state protoimpl.MessageState
@@ -215,7 +129,7 @@ type ReadRequest struct {
func (x *ReadRequest) Reset() {
*x = ReadRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[3]
mi := &file_proto_file_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -228,7 +142,7 @@ func (x *ReadRequest) String() string {
func (*ReadRequest) ProtoMessage() {}
func (x *ReadRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[3]
mi := &file_proto_file_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -241,7 +155,7 @@ func (x *ReadRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ReadRequest.ProtoReflect.Descriptor instead.
func (*ReadRequest) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{3}
return file_proto_file_proto_rawDescGZIP(), []int{1}
}
func (x *ReadRequest) GetProject() string {
@@ -270,7 +184,7 @@ type ReadResponse struct {
func (x *ReadResponse) Reset() {
*x = ReadResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[4]
mi := &file_proto_file_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -283,7 +197,7 @@ func (x *ReadResponse) String() string {
func (*ReadResponse) ProtoMessage() {}
func (x *ReadResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[4]
mi := &file_proto_file_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -296,7 +210,7 @@ func (x *ReadResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ReadResponse.ProtoReflect.Descriptor instead.
func (*ReadResponse) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{4}
return file_proto_file_proto_rawDescGZIP(), []int{2}
}
func (x *ReadResponse) GetFile() *Record {
@@ -318,7 +232,7 @@ type SaveRequest struct {
func (x *SaveRequest) Reset() {
*x = SaveRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[5]
mi := &file_proto_file_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -331,7 +245,7 @@ func (x *SaveRequest) String() string {
func (*SaveRequest) ProtoMessage() {}
func (x *SaveRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[5]
mi := &file_proto_file_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -344,7 +258,7 @@ func (x *SaveRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SaveRequest.ProtoReflect.Descriptor instead.
func (*SaveRequest) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{5}
return file_proto_file_proto_rawDescGZIP(), []int{3}
}
func (x *SaveRequest) GetFile() *Record {
@@ -363,7 +277,7 @@ type SaveResponse struct {
func (x *SaveResponse) Reset() {
*x = SaveResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[6]
mi := &file_proto_file_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -376,7 +290,7 @@ func (x *SaveResponse) String() string {
func (*SaveResponse) ProtoMessage() {}
func (x *SaveResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[6]
mi := &file_proto_file_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -389,10 +303,10 @@ func (x *SaveResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use SaveResponse.ProtoReflect.Descriptor instead.
func (*SaveResponse) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{6}
return file_proto_file_proto_rawDescGZIP(), []int{4}
}
// List file by their project and optionally a path.
// List files by their project and optionally a path.
type ListRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -401,7 +315,7 @@ type ListRequest struct {
// Project, required for listing.
Project string `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"`
// Defaults to '/', ie. lists all files in a project.
// Supply path if of a folder if you want to list
// Supply path to a folder if you want to list
// files inside that folder
// eg. '/docs'
Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"`
@@ -410,7 +324,7 @@ type ListRequest struct {
func (x *ListRequest) Reset() {
*x = ListRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[7]
mi := &file_proto_file_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -423,7 +337,7 @@ func (x *ListRequest) String() string {
func (*ListRequest) ProtoMessage() {}
func (x *ListRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[7]
mi := &file_proto_file_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -436,7 +350,7 @@ func (x *ListRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListRequest.ProtoReflect.Descriptor instead.
func (*ListRequest) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{7}
return file_proto_file_proto_rawDescGZIP(), []int{5}
}
func (x *ListRequest) GetProject() string {
@@ -464,7 +378,7 @@ type ListResponse struct {
func (x *ListResponse) Reset() {
*x = ListResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[8]
mi := &file_proto_file_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -477,7 +391,7 @@ func (x *ListResponse) String() string {
func (*ListResponse) ProtoMessage() {}
func (x *ListResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[8]
mi := &file_proto_file_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -490,7 +404,7 @@ func (x *ListResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use ListResponse.ProtoReflect.Descriptor instead.
func (*ListResponse) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{8}
return file_proto_file_proto_rawDescGZIP(), []int{6}
}
func (x *ListResponse) GetFiles() []*Record {
@@ -515,7 +429,7 @@ type DeleteRequest struct {
func (x *DeleteRequest) Reset() {
*x = DeleteRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[9]
mi := &file_proto_file_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -528,7 +442,7 @@ func (x *DeleteRequest) String() string {
func (*DeleteRequest) ProtoMessage() {}
func (x *DeleteRequest) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[9]
mi := &file_proto_file_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -541,7 +455,7 @@ func (x *DeleteRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use DeleteRequest.ProtoReflect.Descriptor instead.
func (*DeleteRequest) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{9}
return file_proto_file_proto_rawDescGZIP(), []int{7}
}
func (x *DeleteRequest) GetProject() string {
@@ -567,7 +481,7 @@ type DeleteResponse struct {
func (x *DeleteResponse) Reset() {
*x = DeleteResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_file_proto_msgTypes[10]
mi := &file_proto_file_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -580,7 +494,7 @@ func (x *DeleteResponse) String() string {
func (*DeleteResponse) ProtoMessage() {}
func (x *DeleteResponse) ProtoReflect() protoreflect.Message {
mi := &file_proto_file_proto_msgTypes[10]
mi := &file_proto_file_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -593,7 +507,7 @@ func (x *DeleteResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use DeleteResponse.ProtoReflect.Descriptor instead.
func (*DeleteResponse) Descriptor() ([]byte, []int) {
return file_proto_file_proto_rawDescGZIP(), []int{10}
return file_proto_file_proto_rawDescGZIP(), []int{8}
}
var File_proto_file_proto protoreflect.FileDescriptor
@@ -616,49 +530,45 @@ var file_proto_file_proto_rawDesc = []byte{
0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61,
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x3a, 0x02, 0x38, 0x01, 0x22, 0x36, 0x0a, 0x10, 0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x61, 0x76,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52,
0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x13, 0x0a, 0x11,
0x42, 0x61, 0x74, 0x63, 0x68, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x3b, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61,
0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x30,
0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20,
0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x66,
0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65,
0x22, 0x2f, 0x0a, 0x0b, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x20, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e,
0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x04, 0x66, 0x69, 0x6c,
0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x3b, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61,
0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x32,
0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x22,
0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e,
0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05, 0x66, 0x69, 0x6c,
0x65, 0x73, 0x22, 0x3d, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75,
0x3a, 0x02, 0x38, 0x01, 0x22, 0x3b, 0x0a, 0x0b, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74,
0x68, 0x22, 0x10, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x32, 0xd0, 0x01, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x2f, 0x0a, 0x04,
0x52, 0x65, 0x61, 0x64, 0x12, 0x11, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x61, 0x64,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52,
0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2f, 0x0a,
0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x4c, 0x69, 0x73,
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e,
0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2f,
0x0a, 0x04, 0x53, 0x61, 0x76, 0x65, 0x12, 0x11, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x53, 0x61,
0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66, 0x69, 0x6c, 0x65,
0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x35, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x13, 0x2e, 0x66, 0x69, 0x6c, 0x65,
0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14,
0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x3b, 0x66, 0x69, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x68, 0x22, 0x30, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x20, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0c, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x04, 0x66,
0x69, 0x6c, 0x65, 0x22, 0x2f, 0x0a, 0x0b, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x20, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x0c, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x04,
0x66, 0x69, 0x6c, 0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3b, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74,
0x68, 0x22, 0x32, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x22, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x0c, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x52, 0x05,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x3d, 0x0a, 0x0d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x70, 0x61, 0x74, 0x68, 0x22, 0x10, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd0, 0x01, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65, 0x12,
0x2f, 0x0a, 0x04, 0x52, 0x65, 0x61, 0x64, 0x12, 0x11, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x52,
0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66, 0x69, 0x6c,
0x65, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x2f, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e,
0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66, 0x69,
0x6c, 0x65, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x2f, 0x0a, 0x04, 0x53, 0x61, 0x76, 0x65, 0x12, 0x11, 0x2e, 0x66, 0x69, 0x6c, 0x65,
0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x66,
0x69, 0x6c, 0x65, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x35, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x13, 0x2e, 0x66,
0x69, 0x6c, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x14, 0x2e, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x66, 0x69, 0x6c, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
@@ -673,40 +583,37 @@ func file_proto_file_proto_rawDescGZIP() []byte {
return file_proto_file_proto_rawDescData
}
var file_proto_file_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_proto_file_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_proto_file_proto_goTypes = []interface{}{
(*Record)(nil), // 0: file.Record
(*BatchSaveRequest)(nil), // 1: file.BatchSaveRequest
(*BatchSaveResponse)(nil), // 2: file.BatchSaveResponse
(*ReadRequest)(nil), // 3: file.ReadRequest
(*ReadResponse)(nil), // 4: file.ReadResponse
(*SaveRequest)(nil), // 5: file.SaveRequest
(*SaveResponse)(nil), // 6: file.SaveResponse
(*ListRequest)(nil), // 7: file.ListRequest
(*ListResponse)(nil), // 8: file.ListResponse
(*DeleteRequest)(nil), // 9: file.DeleteRequest
(*DeleteResponse)(nil), // 10: file.DeleteResponse
nil, // 11: file.Record.MetadataEntry
(*Record)(nil), // 0: file.Record
(*ReadRequest)(nil), // 1: file.ReadRequest
(*ReadResponse)(nil), // 2: file.ReadResponse
(*SaveRequest)(nil), // 3: file.SaveRequest
(*SaveResponse)(nil), // 4: file.SaveResponse
(*ListRequest)(nil), // 5: file.ListRequest
(*ListResponse)(nil), // 6: file.ListResponse
(*DeleteRequest)(nil), // 7: file.DeleteRequest
(*DeleteResponse)(nil), // 8: file.DeleteResponse
nil, // 9: file.Record.MetadataEntry
}
var file_proto_file_proto_depIdxs = []int32{
11, // 0: file.Record.metadata:type_name -> file.Record.MetadataEntry
0, // 1: file.BatchSaveRequest.files:type_name -> file.Record
0, // 2: file.ReadResponse.file:type_name -> file.Record
0, // 3: file.SaveRequest.file:type_name -> file.Record
0, // 4: file.ListResponse.files:type_name -> file.Record
3, // 5: file.File.Read:input_type -> file.ReadRequest
7, // 6: file.File.List:input_type -> file.ListRequest
5, // 7: file.File.Save:input_type -> file.SaveRequest
9, // 8: file.File.Delete:input_type -> file.DeleteRequest
4, // 9: file.File.Read:output_type -> file.ReadResponse
8, // 10: file.File.List:output_type -> file.ListResponse
6, // 11: file.File.Save:output_type -> file.SaveResponse
10, // 12: file.File.Delete:output_type -> file.DeleteResponse
9, // [9:13] is the sub-list for method output_type
5, // [5:9] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
9, // 0: file.Record.metadata:type_name -> file.Record.MetadataEntry
0, // 1: file.ReadResponse.file:type_name -> file.Record
0, // 2: file.SaveRequest.file:type_name -> file.Record
0, // 3: file.ListResponse.files:type_name -> file.Record
1, // 4: file.File.Read:input_type -> file.ReadRequest
5, // 5: file.File.List:input_type -> file.ListRequest
3, // 6: file.File.Save:input_type -> file.SaveRequest
7, // 7: file.File.Delete:input_type -> file.DeleteRequest
2, // 8: file.File.Read:output_type -> file.ReadResponse
6, // 9: file.File.List:output_type -> file.ListResponse
4, // 10: file.File.Save:output_type -> file.SaveResponse
8, // 11: file.File.Delete:output_type -> file.DeleteResponse
8, // [8:12] is the sub-list for method output_type
4, // [4:8] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_proto_file_proto_init() }
@@ -728,30 +635,6 @@ func file_proto_file_proto_init() {
}
}
file_proto_file_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BatchSaveRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_file_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BatchSaveResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_proto_file_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ReadRequest); i {
case 0:
return &v.state
@@ -763,7 +646,7 @@ func file_proto_file_proto_init() {
return nil
}
}
file_proto_file_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
file_proto_file_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ReadResponse); i {
case 0:
return &v.state
@@ -775,7 +658,7 @@ func file_proto_file_proto_init() {
return nil
}
}
file_proto_file_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
file_proto_file_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SaveRequest); i {
case 0:
return &v.state
@@ -787,7 +670,7 @@ func file_proto_file_proto_init() {
return nil
}
}
file_proto_file_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
file_proto_file_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SaveResponse); i {
case 0:
return &v.state
@@ -799,7 +682,7 @@ func file_proto_file_proto_init() {
return nil
}
}
file_proto_file_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
file_proto_file_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListRequest); i {
case 0:
return &v.state
@@ -811,7 +694,7 @@ func file_proto_file_proto_init() {
return nil
}
}
file_proto_file_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
file_proto_file_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListResponse); i {
case 0:
return &v.state
@@ -823,7 +706,7 @@ func file_proto_file_proto_init() {
return nil
}
}
file_proto_file_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
file_proto_file_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteRequest); i {
case 0:
return &v.state
@@ -835,7 +718,7 @@ func file_proto_file_proto_init() {
return nil
}
}
file_proto_file_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
file_proto_file_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DeleteResponse); i {
case 0:
return &v.state
@@ -854,7 +737,7 @@ func file_proto_file_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_file_proto_rawDesc,
NumEnums: 0,
NumMessages: 12,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -27,14 +27,6 @@ message Record {
map<string,string> metadata = 6;
}
// Batch save multiple files in one call
message BatchSaveRequest {
repeated Record files = 1;
}
message BatchSaveResponse {
}
// Read a file by path
message ReadRequest {
// Project name