diff --git a/core/grpc/server/dependency_service_server.go b/core/grpc/server/dependency_service_server.go index b6a0c1caa..075aedcda 100644 --- a/core/grpc/server/dependency_service_server.go +++ b/core/grpc/server/dependency_service_server.go @@ -145,7 +145,6 @@ func (svr DependencyServiceServer) Sync(_ context.Context, request *grpc.Depende } func (svr DependencyServiceServer) UpdateLogs(stream grpc.DependencyService_UpdateLogsServer) (err error) { - var dep *models.Dependency for { // receive message req, err := stream.Recv() @@ -157,26 +156,19 @@ func (svr DependencyServiceServer) UpdateLogs(stream grpc.DependencyService_Upda return err } - // if dependency is nil, get dependency - if dep == nil { - id, err := primitive.ObjectIDFromHex(req.DependencyId) - if err != nil { - log.Errorf("[DependencyServiceServer] convert dependency id error: %v", err) - return err - } - dep, err = service.NewModelService[models.Dependency]().GetById(id) - if err != nil { - log.Errorf("[DependencyServiceServer] get dependency error: %v", err) - return err - } + // get id + id, err := primitive.ObjectIDFromHex(req.TargetId) + if err != nil { + log.Errorf("[DependencyServiceServer] convert dependency id error: %v", err) + return err } // insert dependency logs var depLogs []models.DependencyLog for _, line := range req.Logs { depLog := models.DependencyLog{ - DependencyId: dep.Id, - Content: line, + TargetId: id, + Content: line, } depLogs = append(depLogs, depLog) } @@ -188,6 +180,57 @@ func (svr DependencyServiceServer) UpdateLogs(stream grpc.DependencyService_Upda } } +func (svr DependencyServiceServer) SyncConfigSetup(_ context.Context, request *grpc.DependencyServiceSyncConfigSetupRequest) (response *grpc.Response, err error) { + // Get node by node key + n, err := service.NewModelService[models.Node]().GetOne(bson.M{"key": request.NodeKey}, nil) + if err != nil { + return nil, err + } + + // Get config + cfg, err := service.NewModelService[models.DependencyConfig]().GetOne(bson.M{"key": request.Lang}, nil) + if err != nil { + return nil, err + } + + // Get config setup for the node + cs, err := service.NewModelService[models.DependencyConfigSetup]().GetOne(bson.M{ + "node_id": n.Id, + "dependency_config_id": cfg.Id, + }, nil) + if err != nil { + if !errors.Is(err, mongo.ErrNoDocuments) { + log.Errorf("[DependencyService] get dependency config setup from db error: %v", err) + return nil, err + } + } + + if cs == nil { + // Create new config setup + cs = &models.DependencyConfigSetup{ + NodeId: n.Id, + DependencyConfigId: cfg.Id, + Status: request.Status, + Error: request.Error, + } + _, err = service.NewModelService[models.DependencyConfigSetup]().InsertOne(*cs) + if err != nil { + log.Errorf("[DependencyService] insert dependency config setup error: %v", err) + return nil, err + } + } else { + // Update existing config setup + cs.Status = request.Status + cs.Error = request.Error + err = service.NewModelService[models.DependencyConfigSetup]().ReplaceById(cs.Id, *cs) + if err != nil { + log.Errorf("[DependencyService] update dependency config setup error: %v", err) + return nil, err + } + } + return nil, nil +} + func (svr DependencyServiceServer) GetStream(key string) (stream *grpc.DependencyService_ConnectServer, err error) { svr.mu.Lock() defer svr.mu.Unlock() diff --git a/core/models/models/dependency.go b/core/models/models/dependency.go index a6e7d4f7a..4099cda67 100644 --- a/core/models/models/dependency.go +++ b/core/models/models/dependency.go @@ -14,7 +14,6 @@ type Dependency struct { Version string `json:"version" bson:"version"` Status string `json:"status" bson:"status"` Error string `json:"error,omitempty" bson:"error,omitempty"` - Logs []string `json:"logs,omitempty" bson:"logs,omitempty"` NodeIds []primitive.ObjectID `json:"node_ids,omitempty" bson:"-"` Versions []string `json:"versions,omitempty" bson:"-"` } diff --git a/core/models/models/dependency_config.go b/core/models/models/dependency_config.go index a36000326..58a5d39c0 100644 --- a/core/models/models/dependency_config.go +++ b/core/models/models/dependency_config.go @@ -3,10 +3,9 @@ package models type DependencyConfig struct { any `collection:"dependency_configs"` BaseModel[DependencyConfig] `bson:",inline"` - Key string `json:"key" bson:"key"` - Name string `json:"name" bson:"name"` - Cmd string `json:"cmd" bson:"cmd"` - Proxy string `json:"proxy" bson:"proxy"` - SetupNodeIds []string `json:"setup_node_ids" bson:"setup_node_ids"` - SetupScriptPath string `json:"setup_script_path" bson:"setup_script_path"` + Key string `json:"key" bson:"key"` + Name string `json:"name" bson:"name"` + ExecCmd string `json:"exec_cmd" bson:"exec_cmd"` + PkgCmd string `json:"pkg_cmd" bson:"pkg_cmd"` + Proxy string `json:"proxy" bson:"proxy"` } diff --git a/core/models/models/dependency_config_setup.go b/core/models/models/dependency_config_setup.go new file mode 100644 index 000000000..00a5c1fb0 --- /dev/null +++ b/core/models/models/dependency_config_setup.go @@ -0,0 +1,13 @@ +package models + +import "go.mongodb.org/mongo-driver/bson/primitive" + +type DependencyConfigSetup struct { + any `collection:"dependency_config_setups"` + BaseModel[DependencyConfigSetup] `bson:",inline"` + DependencyConfigId primitive.ObjectID `json:"dependency_config_id" bson:"dependency_config_id"` + NodeId primitive.ObjectID `json:"node_id" bson:"node_id"` + Version string `json:"version" bson:"version"` + Status string `json:"status" bson:"status"` + Error string `json:"error,omitempty" bson:"error,omitempty"` +} diff --git a/core/models/models/dependency_log.go b/core/models/models/dependency_log.go index 7fd213717..415245ce9 100644 --- a/core/models/models/dependency_log.go +++ b/core/models/models/dependency_log.go @@ -5,6 +5,6 @@ import "go.mongodb.org/mongo-driver/bson/primitive" type DependencyLog struct { any `collection:"dependency_logs"` BaseModel[DependencyLog] `bson:",inline"` - DependencyId primitive.ObjectID `json:"dependency_id" bson:"dependency_id"` + TargetId primitive.ObjectID `json:"target_id" bson:"target_id"` Content string `json:"content" bson:"content"` } diff --git a/core/utils/config.go b/core/utils/config.go index 54457bceb..df37f3762 100644 --- a/core/utils/config.go +++ b/core/utils/config.go @@ -10,24 +10,25 @@ import ( ) const ( - DefaultWorkspace = "crawlab_workspace" - DefaultTaskLogPath = "/var/log/crawlab/tasks" - DefaultServerHost = "0.0.0.0" - DefaultServerPort = 8000 - DefaultGrpcHost = "localhost" - DefaultGrpcPort = 9666 - DefaultGrpcServerHost = "0.0.0.0" - DefaultGrpcServerPort = 9666 - DefaultAuthKey = "Crawlab2024!" - DefaultApiEndpoint = "http://localhost:8000" - DefaultApiAllowOrigin = "*" - DefaultApiAllowCredentials = "true" - DefaultApiAllowMethods = "DELETE, POST, OPTIONS, GET, PUT" - DefaultApiAllowHeaders = "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With" - DefaultNodeMaxRunners = 0 // 0 means no limit - MetadataConfigDirName = ".crawlab" - MetadataConfigName = "config.json" - PyenvRoot = "/root/.pyenv" + DefaultWorkspace = "crawlab_workspace" + DefaultTaskLogPath = "/var/log/crawlab/tasks" + DefaultServerHost = "0.0.0.0" + DefaultServerPort = 8000 + DefaultGrpcHost = "localhost" + DefaultGrpcPort = 9666 + DefaultGrpcServerHost = "0.0.0.0" + DefaultGrpcServerPort = 9666 + DefaultAuthKey = "Crawlab2024!" + DefaultApiEndpoint = "http://localhost:8000" + DefaultApiAllowOrigin = "*" + DefaultApiAllowCredentials = "true" + DefaultApiAllowMethods = "DELETE, POST, OPTIONS, GET, PUT" + DefaultApiAllowHeaders = "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With" + DefaultNodeMaxRunners = 0 // 0 means no limit + DefaultDependencySetupScriptRoot = "/app/install" + MetadataConfigDirName = ".crawlab" + MetadataConfigName = "config.json" + PyenvRoot = "/root/.pyenv" ) func IsDev() bool { @@ -221,3 +222,10 @@ func GetMetadataConfigPath() string { return filepath.Join(homeDirPath, MetadataConfigDirName, MetadataConfigName) } + +func GetDependencySetupScriptRoot() string { + if res := viper.GetString("dependency.setupScriptRoot"); res != "" { + return res + } + return DefaultDependencySetupScriptRoot +} diff --git a/grpc/dependency_service.pb.go b/grpc/dependency_service.pb.go index 815767879..3dbfa93ea 100644 --- a/grpc/dependency_service.pb.go +++ b/grpc/dependency_service.pb.go @@ -313,8 +313,8 @@ type DependencyServiceUpdateLogsRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - DependencyId string `protobuf:"bytes,1,opt,name=dependency_id,json=dependencyId,proto3" json:"dependency_id,omitempty"` - Logs []string `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"` + TargetId string `protobuf:"bytes,1,opt,name=target_id,json=targetId,proto3" json:"target_id,omitempty"` + Logs []string `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"` } func (x *DependencyServiceUpdateLogsRequest) Reset() { @@ -349,9 +349,9 @@ func (*DependencyServiceUpdateLogsRequest) Descriptor() ([]byte, []int) { return file_services_dependency_service_proto_rawDescGZIP(), []int{4} } -func (x *DependencyServiceUpdateLogsRequest) GetDependencyId() string { +func (x *DependencyServiceUpdateLogsRequest) GetTargetId() string { if x != nil { - return x.DependencyId + return x.TargetId } return "" } @@ -363,6 +363,77 @@ func (x *DependencyServiceUpdateLogsRequest) GetLogs() []string { return nil } +type DependencyServiceSyncConfigSetupRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NodeKey string `protobuf:"bytes,1,opt,name=node_key,json=nodeKey,proto3" json:"node_key,omitempty"` + Lang string `protobuf:"bytes,2,opt,name=lang,proto3" json:"lang,omitempty"` + Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` + Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *DependencyServiceSyncConfigSetupRequest) Reset() { + *x = DependencyServiceSyncConfigSetupRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_services_dependency_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DependencyServiceSyncConfigSetupRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DependencyServiceSyncConfigSetupRequest) ProtoMessage() {} + +func (x *DependencyServiceSyncConfigSetupRequest) ProtoReflect() protoreflect.Message { + mi := &file_services_dependency_service_proto_msgTypes[5] + 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 DependencyServiceSyncConfigSetupRequest.ProtoReflect.Descriptor instead. +func (*DependencyServiceSyncConfigSetupRequest) Descriptor() ([]byte, []int) { + return file_services_dependency_service_proto_rawDescGZIP(), []int{5} +} + +func (x *DependencyServiceSyncConfigSetupRequest) GetNodeKey() string { + if x != nil { + return x.NodeKey + } + return "" +} + +func (x *DependencyServiceSyncConfigSetupRequest) GetLang() string { + if x != nil { + return x.Lang + } + return "" +} + +func (x *DependencyServiceSyncConfigSetupRequest) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *DependencyServiceSyncConfigSetupRequest) GetError() string { + if x != nil { + return x.Error + } + return "" +} + var File_services_dependency_service_proto protoreflect.FileDescriptor var file_services_dependency_service_proto_rawDesc = []byte{ @@ -397,34 +468,47 @@ var file_services_dependency_service_proto_rawDesc = []byte{ 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, - 0x65, 0x73, 0x22, 0x5d, 0x0a, 0x22, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, + 0x65, 0x73, 0x22, 0x55, 0x0a, 0x22, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x65, 0x70, 0x65, - 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x49, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, - 0x73, 0x2a, 0x48, 0x0a, 0x15, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x59, - 0x4e, 0x43, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, - 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, 0x02, - 0x12, 0x09, 0x0a, 0x05, 0x53, 0x45, 0x54, 0x55, 0x50, 0x10, 0x03, 0x32, 0xfb, 0x01, 0x0a, 0x11, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x86, 0x01, 0x0a, 0x27, 0x44, 0x65, + 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, + 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x65, 0x74, 0x75, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x4b, 0x65, 0x79, + 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6c, 0x61, 0x6e, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x2a, 0x48, 0x0a, 0x15, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x53, + 0x59, 0x4e, 0x43, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, + 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, + 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x45, 0x54, 0x55, 0x50, 0x10, 0x03, 0x32, 0xcf, 0x02, 0x0a, + 0x11, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x5c, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x25, 0x2e, + 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, + 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, + 0x12, 0x3c, 0x0a, 0x04, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x22, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x5c, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x12, 0x25, 0x2e, 0x67, + 0x65, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, + 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x28, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, - 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x6e, - 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, - 0x3c, 0x0a, 0x04, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x22, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, - 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, 0x0a, - 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x28, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x08, 0x5a, 0x06, 0x2e, 0x3b, 0x67, - 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x52, 0x0a, 0x0f, 0x53, 0x79, + 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x65, 0x74, 0x75, 0x70, 0x12, 0x2d, 0x2e, + 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x53, 0x65, 0x74, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08, + 0x5a, 0x06, 0x2e, 0x3b, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -440,15 +524,16 @@ func file_services_dependency_service_proto_rawDescGZIP() []byte { } var file_services_dependency_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_services_dependency_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_services_dependency_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_services_dependency_service_proto_goTypes = []any{ - (DependencyServiceCode)(0), // 0: grpc.DependencyServiceCode - (*Dependency)(nil), // 1: grpc.Dependency - (*DependencyServiceConnectRequest)(nil), // 2: grpc.DependencyServiceConnectRequest - (*DependencyServiceConnectResponse)(nil), // 3: grpc.DependencyServiceConnectResponse - (*DependencyServiceSyncRequest)(nil), // 4: grpc.DependencyServiceSyncRequest - (*DependencyServiceUpdateLogsRequest)(nil), // 5: grpc.DependencyServiceUpdateLogsRequest - (*Response)(nil), // 6: grpc.Response + (DependencyServiceCode)(0), // 0: grpc.DependencyServiceCode + (*Dependency)(nil), // 1: grpc.Dependency + (*DependencyServiceConnectRequest)(nil), // 2: grpc.DependencyServiceConnectRequest + (*DependencyServiceConnectResponse)(nil), // 3: grpc.DependencyServiceConnectResponse + (*DependencyServiceSyncRequest)(nil), // 4: grpc.DependencyServiceSyncRequest + (*DependencyServiceUpdateLogsRequest)(nil), // 5: grpc.DependencyServiceUpdateLogsRequest + (*DependencyServiceSyncConfigSetupRequest)(nil), // 6: grpc.DependencyServiceSyncConfigSetupRequest + (*Response)(nil), // 7: grpc.Response } var file_services_dependency_service_proto_depIdxs = []int32{ 0, // 0: grpc.DependencyServiceConnectResponse.code:type_name -> grpc.DependencyServiceCode @@ -457,11 +542,13 @@ var file_services_dependency_service_proto_depIdxs = []int32{ 2, // 3: grpc.DependencyService.Connect:input_type -> grpc.DependencyServiceConnectRequest 4, // 4: grpc.DependencyService.Sync:input_type -> grpc.DependencyServiceSyncRequest 5, // 5: grpc.DependencyService.UpdateLogs:input_type -> grpc.DependencyServiceUpdateLogsRequest - 3, // 6: grpc.DependencyService.Connect:output_type -> grpc.DependencyServiceConnectResponse - 6, // 7: grpc.DependencyService.Sync:output_type -> grpc.Response - 6, // 8: grpc.DependencyService.UpdateLogs:output_type -> grpc.Response - 6, // [6:9] is the sub-list for method output_type - 3, // [3:6] is the sub-list for method input_type + 6, // 6: grpc.DependencyService.SyncConfigSetup:input_type -> grpc.DependencyServiceSyncConfigSetupRequest + 3, // 7: grpc.DependencyService.Connect:output_type -> grpc.DependencyServiceConnectResponse + 7, // 8: grpc.DependencyService.Sync:output_type -> grpc.Response + 7, // 9: grpc.DependencyService.UpdateLogs:output_type -> grpc.Response + 7, // 10: grpc.DependencyService.SyncConfigSetup:output_type -> grpc.Response + 7, // [7:11] is the sub-list for method output_type + 3, // [3:7] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -534,6 +621,18 @@ func file_services_dependency_service_proto_init() { return nil } } + file_services_dependency_service_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*DependencyServiceSyncConfigSetupRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -541,7 +640,7 @@ func file_services_dependency_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_services_dependency_service_proto_rawDesc, NumEnums: 1, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 1, }, diff --git a/grpc/dependency_service_grpc.pb.go b/grpc/dependency_service_grpc.pb.go index a0c7124f8..9680891bc 100644 --- a/grpc/dependency_service_grpc.pb.go +++ b/grpc/dependency_service_grpc.pb.go @@ -19,9 +19,10 @@ import ( const _ = grpc.SupportPackageIsVersion8 const ( - DependencyService_Connect_FullMethodName = "/grpc.DependencyService/Connect" - DependencyService_Sync_FullMethodName = "/grpc.DependencyService/Sync" - DependencyService_UpdateLogs_FullMethodName = "/grpc.DependencyService/UpdateLogs" + DependencyService_Connect_FullMethodName = "/grpc.DependencyService/Connect" + DependencyService_Sync_FullMethodName = "/grpc.DependencyService/Sync" + DependencyService_UpdateLogs_FullMethodName = "/grpc.DependencyService/UpdateLogs" + DependencyService_SyncConfigSetup_FullMethodName = "/grpc.DependencyService/SyncConfigSetup" ) // DependencyServiceClient is the client API for DependencyService service. @@ -31,6 +32,7 @@ type DependencyServiceClient interface { Connect(ctx context.Context, in *DependencyServiceConnectRequest, opts ...grpc.CallOption) (DependencyService_ConnectClient, error) Sync(ctx context.Context, in *DependencyServiceSyncRequest, opts ...grpc.CallOption) (*Response, error) UpdateLogs(ctx context.Context, opts ...grpc.CallOption) (DependencyService_UpdateLogsClient, error) + SyncConfigSetup(ctx context.Context, in *DependencyServiceSyncConfigSetupRequest, opts ...grpc.CallOption) (*Response, error) } type dependencyServiceClient struct { @@ -119,6 +121,16 @@ func (x *dependencyServiceUpdateLogsClient) CloseAndRecv() (*Response, error) { return m, nil } +func (c *dependencyServiceClient) SyncConfigSetup(ctx context.Context, in *DependencyServiceSyncConfigSetupRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, DependencyService_SyncConfigSetup_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // DependencyServiceServer is the server API for DependencyService service. // All implementations must embed UnimplementedDependencyServiceServer // for forward compatibility @@ -126,6 +138,7 @@ type DependencyServiceServer interface { Connect(*DependencyServiceConnectRequest, DependencyService_ConnectServer) error Sync(context.Context, *DependencyServiceSyncRequest) (*Response, error) UpdateLogs(DependencyService_UpdateLogsServer) error + SyncConfigSetup(context.Context, *DependencyServiceSyncConfigSetupRequest) (*Response, error) mustEmbedUnimplementedDependencyServiceServer() } @@ -142,6 +155,9 @@ func (UnimplementedDependencyServiceServer) Sync(context.Context, *DependencySer func (UnimplementedDependencyServiceServer) UpdateLogs(DependencyService_UpdateLogsServer) error { return status.Errorf(codes.Unimplemented, "method UpdateLogs not implemented") } +func (UnimplementedDependencyServiceServer) SyncConfigSetup(context.Context, *DependencyServiceSyncConfigSetupRequest) (*Response, error) { + return nil, status.Errorf(codes.Unimplemented, "method SyncConfigSetup not implemented") +} func (UnimplementedDependencyServiceServer) mustEmbedUnimplementedDependencyServiceServer() {} // UnsafeDependencyServiceServer may be embedded to opt out of forward compatibility for this service. @@ -220,6 +236,24 @@ func (x *dependencyServiceUpdateLogsServer) Recv() (*DependencyServiceUpdateLogs return m, nil } +func _DependencyService_SyncConfigSetup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DependencyServiceSyncConfigSetupRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DependencyServiceServer).SyncConfigSetup(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DependencyService_SyncConfigSetup_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DependencyServiceServer).SyncConfigSetup(ctx, req.(*DependencyServiceSyncConfigSetupRequest)) + } + return interceptor(ctx, in, info, handler) +} + // DependencyService_ServiceDesc is the grpc.ServiceDesc for DependencyService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -231,6 +265,10 @@ var DependencyService_ServiceDesc = grpc.ServiceDesc{ MethodName: "Sync", Handler: _DependencyService_Sync_Handler, }, + { + MethodName: "SyncConfigSetup", + Handler: _DependencyService_SyncConfigSetup_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/grpc/proto/services/dependency_service.proto b/grpc/proto/services/dependency_service.proto index afa7f1589..5722e8203 100644 --- a/grpc/proto/services/dependency_service.proto +++ b/grpc/proto/services/dependency_service.proto @@ -35,12 +35,20 @@ message DependencyServiceSyncRequest { } message DependencyServiceUpdateLogsRequest { - string dependency_id = 1; + string target_id = 1; repeated string logs = 2; } +message DependencyServiceSyncConfigSetupRequest { + string node_key = 1; + string lang = 2; + string status = 3; + string error = 4; +} + service DependencyService { rpc Connect(DependencyServiceConnectRequest) returns (stream DependencyServiceConnectResponse){}; rpc Sync(DependencyServiceSyncRequest) returns (Response){}; rpc UpdateLogs(stream DependencyServiceUpdateLogsRequest) returns (Response){}; + rpc SyncConfigSetup(DependencyServiceSyncConfigSetupRequest) returns (Response){}; }