add rebuild gprc command

This commit is contained in:
Arnas Udovicius 2022-08-22 22:53:27 +03:00
parent a235a1adc1
commit d0d3c2be08
5 changed files with 318 additions and 106 deletions

View file

@ -8,6 +8,7 @@ import (
var (
source string
dest string
key string
meta = []string{"description", "lang", "copyright", "created"} //_ = zord_tree.PopulateTree(cfg.MdTree.Path, cfg.MdTree.DPath, meta)
customMeta = make(map[string]func() string)
)
@ -15,6 +16,7 @@ var (
func init() {
flag.StringVar(&dest, "dest", "", "destination directory to read from")
flag.StringVar(&source, "source", "", "source to collect texts.")
flag.StringVar(&key, "key", "", "secret key for authenticated communication.")
flag.Parse()
customMeta["copyright"] = func() string {

View file

@ -6,6 +6,7 @@ import (
"log"
"net"
"os"
"path/filepath"
zordTree "g.arns.lt/zordsdavini/zord-tree"
)
@ -64,6 +65,39 @@ func (TreeManagerServer *server) GetFile(_ context.Context, in *FileRequest) (*F
return &fileContent, nil
}
func (TreeManagerServer *server) RebuildTree(ctx context.Context, in *TreeSecret) (*RebuildResponse, error) {
success := false
if in.Key == key {
err := removeContents(dest)
if err == nil {
Collect()
success = true
}
}
response := RebuildResponse{Success: success}
return &response, nil
}
func removeContents(dir string) error {
d, err := os.Open(dir)
if err != nil {
return err
}
defer d.Close()
names, err := d.Readdirnames(-1)
if err != nil {
return err
}
for _, name := range names {
err = os.RemoveAll(filepath.Join(dir, name))
if err != nil {
return err
}
}
return nil
}
func simplifyFilter(filter []*TreeRequest_Filter) map[string]string {
simpleFilter := make(map[string]string)
for _, f := range filter {

View file

@ -20,6 +20,100 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type TreeSecret struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}
func (x *TreeSecret) Reset() {
*x = TreeSecret{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TreeSecret) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TreeSecret) ProtoMessage() {}
func (x *TreeSecret) ProtoReflect() protoreflect.Message {
mi := &file_tree_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TreeSecret.ProtoReflect.Descriptor instead.
func (*TreeSecret) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{0}
}
func (x *TreeSecret) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
type RebuildResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
}
func (x *RebuildResponse) Reset() {
*x = RebuildResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RebuildResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RebuildResponse) ProtoMessage() {}
func (x *RebuildResponse) ProtoReflect() protoreflect.Message {
mi := &file_tree_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 RebuildResponse.ProtoReflect.Descriptor instead.
func (*RebuildResponse) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{1}
}
func (x *RebuildResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
type FileRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -31,7 +125,7 @@ type FileRequest struct {
func (x *FileRequest) Reset() {
*x = FileRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[0]
mi := &file_tree_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -44,7 +138,7 @@ func (x *FileRequest) String() string {
func (*FileRequest) ProtoMessage() {}
func (x *FileRequest) ProtoReflect() protoreflect.Message {
mi := &file_tree_proto_msgTypes[0]
mi := &file_tree_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -57,7 +151,7 @@ func (x *FileRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use FileRequest.ProtoReflect.Descriptor instead.
func (*FileRequest) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{0}
return file_tree_proto_rawDescGZIP(), []int{2}
}
func (x *FileRequest) GetId() string {
@ -79,7 +173,7 @@ type TreeRequest struct {
func (x *TreeRequest) Reset() {
*x = TreeRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[1]
mi := &file_tree_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -92,7 +186,7 @@ func (x *TreeRequest) String() string {
func (*TreeRequest) ProtoMessage() {}
func (x *TreeRequest) ProtoReflect() protoreflect.Message {
mi := &file_tree_proto_msgTypes[1]
mi := &file_tree_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -105,7 +199,7 @@ func (x *TreeRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use TreeRequest.ProtoReflect.Descriptor instead.
func (*TreeRequest) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{1}
return file_tree_proto_rawDescGZIP(), []int{3}
}
func (x *TreeRequest) GetPath() string {
@ -140,7 +234,7 @@ type TreeFile struct {
func (x *TreeFile) Reset() {
*x = TreeFile{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[2]
mi := &file_tree_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -153,7 +247,7 @@ func (x *TreeFile) String() string {
func (*TreeFile) ProtoMessage() {}
func (x *TreeFile) ProtoReflect() protoreflect.Message {
mi := &file_tree_proto_msgTypes[2]
mi := &file_tree_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -166,7 +260,7 @@ func (x *TreeFile) ProtoReflect() protoreflect.Message {
// Deprecated: Use TreeFile.ProtoReflect.Descriptor instead.
func (*TreeFile) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{2}
return file_tree_proto_rawDescGZIP(), []int{4}
}
func (x *TreeFile) GetName() string {
@ -241,7 +335,7 @@ type Tree struct {
func (x *Tree) Reset() {
*x = Tree{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[3]
mi := &file_tree_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -254,7 +348,7 @@ func (x *Tree) String() string {
func (*Tree) ProtoMessage() {}
func (x *Tree) ProtoReflect() protoreflect.Message {
mi := &file_tree_proto_msgTypes[3]
mi := &file_tree_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -267,7 +361,7 @@ func (x *Tree) ProtoReflect() protoreflect.Message {
// Deprecated: Use Tree.ProtoReflect.Descriptor instead.
func (*Tree) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{3}
return file_tree_proto_rawDescGZIP(), []int{5}
}
func (x *Tree) GetFiles() []*TreeFile {
@ -324,7 +418,7 @@ type FileContent struct {
func (x *FileContent) Reset() {
*x = FileContent{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[4]
mi := &file_tree_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -337,7 +431,7 @@ func (x *FileContent) String() string {
func (*FileContent) ProtoMessage() {}
func (x *FileContent) ProtoReflect() protoreflect.Message {
mi := &file_tree_proto_msgTypes[4]
mi := &file_tree_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -350,7 +444,7 @@ func (x *FileContent) ProtoReflect() protoreflect.Message {
// Deprecated: Use FileContent.ProtoReflect.Descriptor instead.
func (*FileContent) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{4}
return file_tree_proto_rawDescGZIP(), []int{6}
}
func (x *FileContent) GetFile() *TreeFile {
@ -379,7 +473,7 @@ type TreeRequest_Filter struct {
func (x *TreeRequest_Filter) Reset() {
*x = TreeRequest_Filter{}
if protoimpl.UnsafeEnabled {
mi := &file_tree_proto_msgTypes[5]
mi := &file_tree_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -392,7 +486,7 @@ func (x *TreeRequest_Filter) String() string {
func (*TreeRequest_Filter) ProtoMessage() {}
func (x *TreeRequest_Filter) ProtoReflect() protoreflect.Message {
mi := &file_tree_proto_msgTypes[5]
mi := &file_tree_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -405,7 +499,7 @@ func (x *TreeRequest_Filter) ProtoReflect() protoreflect.Message {
// Deprecated: Use TreeRequest_Filter.ProtoReflect.Descriptor instead.
func (*TreeRequest_Filter) Descriptor() ([]byte, []int) {
return file_tree_proto_rawDescGZIP(), []int{1, 0}
return file_tree_proto_rawDescGZIP(), []int{3, 0}
}
func (x *TreeRequest_Filter) GetKey() string {
@ -426,66 +520,75 @@ var File_tree_proto protoreflect.FileDescriptor
var file_tree_proto_rawDesc = []byte{
0x0a, 0x0a, 0x74, 0x72, 0x65, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x6d, 0x61,
0x69, 0x6e, 0x22, 0x1d, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69,
0x64, 0x22, 0x93, 0x01, 0x0a, 0x0b, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x12, 0x17, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48,
0x00, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x06, 0x66, 0x69,
0x6c, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x61, 0x69,
0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x46, 0x69,
0x6c, 0x74, 0x65, 0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x1a, 0x30, 0x0a, 0x06,
0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 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, 0x42, 0x07,
0x0a, 0x05, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x22, 0xcc, 0x01, 0x0a, 0x08, 0x54, 0x72, 0x65, 0x65,
0x46, 0x69, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x74, 0x65,
0x67, 0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x61, 0x74, 0x65,
0x67, 0x6f, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x05,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f,
0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63,
0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73,
0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x22, 0xe8, 0x02, 0x0a, 0x04, 0x54, 0x72, 0x65, 0x65, 0x12,
0x24, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x46, 0x69, 0x6c,
0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e,
0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x46, 0x69,
0x6c, 0x65, 0x73, 0x12, 0x28, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x14, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x2e, 0x54, 0x61,
0x67, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x3a, 0x0a,
0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x1a, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x2e, 0x43, 0x61,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x63,
0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74,
0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1a, 0x0a,
0x08, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x72, 0x6f, 0x6f, 0x74, 0x50, 0x61, 0x74, 0x68, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67,
0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02,
0x38, 0x01, 0x1a, 0x3d, 0x0a, 0x0f, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38,
0x01, 0x22, 0x4b, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
0x12, 0x22, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x04,
0x66, 0x69, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x32, 0x6f,
0x0a, 0x0b, 0x54, 0x72, 0x65, 0x65, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x12, 0x2d, 0x0a,
0x0a, 0x47, 0x65, 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x65, 0x72, 0x79, 0x12, 0x11, 0x2e, 0x6d, 0x61,
0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x07,
0x47, 0x65, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x46,
0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x6d, 0x61, 0x69,
0x6e, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x42,
0x03, 0x5a, 0x01, 0x2e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x69, 0x6e, 0x22, 0x1e, 0x0a, 0x0a, 0x54, 0x72, 0x65, 0x65, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74,
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
0x65, 0x79, 0x22, 0x2b, 0x0a, 0x0f, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73,
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22,
0x1d, 0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x93,
0x01, 0x0a, 0x0b, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17,
0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04,
0x70, 0x61, 0x74, 0x68, 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65,
0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54,
0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x46, 0x69, 0x6c, 0x74, 0x65,
0x72, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x1a, 0x30, 0x0a, 0x06, 0x46, 0x69, 0x6c,
0x74, 0x65, 0x72, 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, 0x42, 0x07, 0x0a, 0x05, 0x5f,
0x70, 0x61, 0x74, 0x68, 0x22, 0xcc, 0x01, 0x0a, 0x08, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c,
0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72,
0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72,
0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x70, 0x79, 0x72,
0x69, 0x67, 0x68, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x70, 0x79,
0x72, 0x69, 0x67, 0x68, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x07, 0x20,
0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x72, 0x65,
0x61, 0x74, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x72, 0x65, 0x61,
0x74, 0x65, 0x64, 0x22, 0xe8, 0x02, 0x0a, 0x04, 0x54, 0x72, 0x65, 0x65, 0x12, 0x24, 0x0a, 0x05,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, 0x61,
0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x05, 0x66, 0x69, 0x6c,
0x65, 0x73, 0x12, 0x2c, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x18,
0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65,
0x65, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x73,
0x12, 0x28, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x2e, 0x54, 0x61, 0x67, 0x73, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x3a, 0x0a, 0x0a, 0x63, 0x61,
0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x2e, 0x43, 0x61, 0x74, 0x65, 0x67,
0x6f, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65,
0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05,
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f,
0x6f, 0x74, 0x50, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f,
0x6f, 0x74, 0x50, 0x61, 0x74, 0x68, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x73, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a,
0x3d, 0x0a, 0x0f, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x4b,
0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x22, 0x0a,
0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6d, 0x61,
0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x04, 0x66, 0x69, 0x6c,
0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x32, 0xa9, 0x01, 0x0a, 0x0b,
0x54, 0x72, 0x65, 0x65, 0x4d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x12, 0x2d, 0x0a, 0x0a, 0x47,
0x65, 0x74, 0x53, 0x75, 0x6d, 0x6d, 0x65, 0x72, 0x79, 0x12, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e,
0x2e, 0x54, 0x72, 0x65, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x6d,
0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x22, 0x00, 0x12, 0x31, 0x0a, 0x07, 0x47, 0x65,
0x74, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x46, 0x69, 0x6c,
0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e,
0x46, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x38, 0x0a,
0x0b, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x72, 0x65, 0x65, 0x12, 0x10, 0x2e, 0x6d,
0x61, 0x69, 0x6e, 0x2e, 0x54, 0x72, 0x65, 0x65, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x1a, 0x15,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x52, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x03, 0x5a, 0x01, 0x2e, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -500,30 +603,34 @@ func file_tree_proto_rawDescGZIP() []byte {
return file_tree_proto_rawDescData
}
var file_tree_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_tree_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_tree_proto_goTypes = []interface{}{
(*FileRequest)(nil), // 0: main.FileRequest
(*TreeRequest)(nil), // 1: main.TreeRequest
(*TreeFile)(nil), // 2: main.TreeFile
(*Tree)(nil), // 3: main.Tree
(*FileContent)(nil), // 4: main.FileContent
(*TreeRequest_Filter)(nil), // 5: main.TreeRequest.Filter
nil, // 6: main.Tree.TagsEntry
nil, // 7: main.Tree.CategoriesEntry
(*TreeSecret)(nil), // 0: main.TreeSecret
(*RebuildResponse)(nil), // 1: main.RebuildResponse
(*FileRequest)(nil), // 2: main.FileRequest
(*TreeRequest)(nil), // 3: main.TreeRequest
(*TreeFile)(nil), // 4: main.TreeFile
(*Tree)(nil), // 5: main.Tree
(*FileContent)(nil), // 6: main.FileContent
(*TreeRequest_Filter)(nil), // 7: main.TreeRequest.Filter
nil, // 8: main.Tree.TagsEntry
nil, // 9: main.Tree.CategoriesEntry
}
var file_tree_proto_depIdxs = []int32{
5, // 0: main.TreeRequest.filter:type_name -> main.TreeRequest.Filter
2, // 1: main.Tree.files:type_name -> main.TreeFile
2, // 2: main.Tree.rootFiles:type_name -> main.TreeFile
6, // 3: main.Tree.tags:type_name -> main.Tree.TagsEntry
7, // 4: main.Tree.categories:type_name -> main.Tree.CategoriesEntry
2, // 5: main.FileContent.file:type_name -> main.TreeFile
1, // 6: main.TreeManager.GetSummery:input_type -> main.TreeRequest
0, // 7: main.TreeManager.GetFile:input_type -> main.FileRequest
3, // 8: main.TreeManager.GetSummery:output_type -> main.Tree
4, // 9: main.TreeManager.GetFile:output_type -> main.FileContent
8, // [8:10] is the sub-list for method output_type
6, // [6:8] is the sub-list for method input_type
7, // 0: main.TreeRequest.filter:type_name -> main.TreeRequest.Filter
4, // 1: main.Tree.files:type_name -> main.TreeFile
4, // 2: main.Tree.rootFiles:type_name -> main.TreeFile
8, // 3: main.Tree.tags:type_name -> main.Tree.TagsEntry
9, // 4: main.Tree.categories:type_name -> main.Tree.CategoriesEntry
4, // 5: main.FileContent.file:type_name -> main.TreeFile
3, // 6: main.TreeManager.GetSummery:input_type -> main.TreeRequest
2, // 7: main.TreeManager.GetFile:input_type -> main.FileRequest
0, // 8: main.TreeManager.RebuildTree:input_type -> main.TreeSecret
5, // 9: main.TreeManager.GetSummery:output_type -> main.Tree
6, // 10: main.TreeManager.GetFile:output_type -> main.FileContent
1, // 11: main.TreeManager.RebuildTree:output_type -> main.RebuildResponse
9, // [9:12] is the sub-list for method output_type
6, // [6:9] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
@ -536,7 +643,7 @@ func file_tree_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_tree_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FileRequest); i {
switch v := v.(*TreeSecret); i {
case 0:
return &v.state
case 1:
@ -548,7 +655,7 @@ func file_tree_proto_init() {
}
}
file_tree_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TreeRequest); i {
switch v := v.(*RebuildResponse); i {
case 0:
return &v.state
case 1:
@ -560,7 +667,7 @@ func file_tree_proto_init() {
}
}
file_tree_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TreeFile); i {
switch v := v.(*FileRequest); i {
case 0:
return &v.state
case 1:
@ -572,7 +679,7 @@ func file_tree_proto_init() {
}
}
file_tree_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Tree); i {
switch v := v.(*TreeRequest); i {
case 0:
return &v.state
case 1:
@ -584,7 +691,7 @@ func file_tree_proto_init() {
}
}
file_tree_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FileContent); i {
switch v := v.(*TreeFile); i {
case 0:
return &v.state
case 1:
@ -596,6 +703,30 @@ func file_tree_proto_init() {
}
}
file_tree_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Tree); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_tree_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FileContent); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_tree_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TreeRequest_Filter); i {
case 0:
return &v.state
@ -608,14 +739,14 @@ func file_tree_proto_init() {
}
}
}
file_tree_proto_msgTypes[1].OneofWrappers = []interface{}{}
file_tree_proto_msgTypes[3].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_tree_proto_rawDesc,
NumEnums: 0,
NumMessages: 8,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},

View file

@ -10,6 +10,15 @@ package main;
service TreeManager {
rpc GetSummery(TreeRequest) returns (Tree) {}
rpc GetFile(FileRequest) returns (FileContent) {}
rpc RebuildTree(TreeSecret) returns (RebuildResponse) {}
}
message TreeSecret {
string key = 1;
}
message RebuildResponse {
bool success = 1;
}
message FileRequest {

View file

@ -24,6 +24,7 @@ const _ = grpc.SupportPackageIsVersion7
type TreeManagerClient interface {
GetSummery(ctx context.Context, in *TreeRequest, opts ...grpc.CallOption) (*Tree, error)
GetFile(ctx context.Context, in *FileRequest, opts ...grpc.CallOption) (*FileContent, error)
RebuildTree(ctx context.Context, in *TreeSecret, opts ...grpc.CallOption) (*RebuildResponse, error)
}
type treeManagerClient struct {
@ -52,12 +53,22 @@ func (c *treeManagerClient) GetFile(ctx context.Context, in *FileRequest, opts .
return out, nil
}
func (c *treeManagerClient) RebuildTree(ctx context.Context, in *TreeSecret, opts ...grpc.CallOption) (*RebuildResponse, error) {
out := new(RebuildResponse)
err := c.cc.Invoke(ctx, "/main.TreeManager/RebuildTree", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TreeManagerServer is the server API for TreeManager service.
// All implementations must embed UnimplementedTreeManagerServer
// for forward compatibility
type TreeManagerServer interface {
GetSummery(context.Context, *TreeRequest) (*Tree, error)
GetFile(context.Context, *FileRequest) (*FileContent, error)
RebuildTree(context.Context, *TreeSecret) (*RebuildResponse, error)
mustEmbedUnimplementedTreeManagerServer()
}
@ -71,6 +82,9 @@ func (UnimplementedTreeManagerServer) GetSummery(context.Context, *TreeRequest)
func (UnimplementedTreeManagerServer) GetFile(context.Context, *FileRequest) (*FileContent, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetFile not implemented")
}
func (UnimplementedTreeManagerServer) RebuildTree(context.Context, *TreeSecret) (*RebuildResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RebuildTree not implemented")
}
func (UnimplementedTreeManagerServer) mustEmbedUnimplementedTreeManagerServer() {}
// UnsafeTreeManagerServer may be embedded to opt out of forward compatibility for this service.
@ -120,6 +134,24 @@ func _TreeManager_GetFile_Handler(srv interface{}, ctx context.Context, dec func
return interceptor(ctx, in, info, handler)
}
func _TreeManager_RebuildTree_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TreeSecret)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TreeManagerServer).RebuildTree(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/main.TreeManager/RebuildTree",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TreeManagerServer).RebuildTree(ctx, req.(*TreeSecret))
}
return interceptor(ctx, in, info, handler)
}
// TreeManager_ServiceDesc is the grpc.ServiceDesc for TreeManager service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -135,6 +167,10 @@ var TreeManager_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetFile",
Handler: _TreeManager_GetFile_Handler,
},
{
MethodName: "RebuildTree",
Handler: _TreeManager_RebuildTree_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "tree.proto",