feat: added dependency config setup (wip)

This commit is contained in:
Marvin Zhang
2024-12-15 23:09:10 +08:00
parent 3b54a63bed
commit c5c08dfba6
9 changed files with 295 additions and 88 deletions

View File

@@ -145,7 +145,6 @@ func (svr DependencyServiceServer) Sync(_ context.Context, request *grpc.Depende
} }
func (svr DependencyServiceServer) UpdateLogs(stream grpc.DependencyService_UpdateLogsServer) (err error) { func (svr DependencyServiceServer) UpdateLogs(stream grpc.DependencyService_UpdateLogsServer) (err error) {
var dep *models.Dependency
for { for {
// receive message // receive message
req, err := stream.Recv() req, err := stream.Recv()
@@ -157,26 +156,19 @@ func (svr DependencyServiceServer) UpdateLogs(stream grpc.DependencyService_Upda
return err return err
} }
// if dependency is nil, get dependency // get id
if dep == nil { id, err := primitive.ObjectIDFromHex(req.TargetId)
id, err := primitive.ObjectIDFromHex(req.DependencyId) if err != nil {
if err != nil { log.Errorf("[DependencyServiceServer] convert dependency id error: %v", err)
log.Errorf("[DependencyServiceServer] convert dependency id error: %v", err) return err
return err
}
dep, err = service.NewModelService[models.Dependency]().GetById(id)
if err != nil {
log.Errorf("[DependencyServiceServer] get dependency error: %v", err)
return err
}
} }
// insert dependency logs // insert dependency logs
var depLogs []models.DependencyLog var depLogs []models.DependencyLog
for _, line := range req.Logs { for _, line := range req.Logs {
depLog := models.DependencyLog{ depLog := models.DependencyLog{
DependencyId: dep.Id, TargetId: id,
Content: line, Content: line,
} }
depLogs = append(depLogs, depLog) 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) { func (svr DependencyServiceServer) GetStream(key string) (stream *grpc.DependencyService_ConnectServer, err error) {
svr.mu.Lock() svr.mu.Lock()
defer svr.mu.Unlock() defer svr.mu.Unlock()

View File

@@ -14,7 +14,6 @@ type Dependency struct {
Version string `json:"version" bson:"version"` Version string `json:"version" bson:"version"`
Status string `json:"status" bson:"status"` Status string `json:"status" bson:"status"`
Error string `json:"error,omitempty" bson:"error,omitempty"` Error string `json:"error,omitempty" bson:"error,omitempty"`
Logs []string `json:"logs,omitempty" bson:"logs,omitempty"`
NodeIds []primitive.ObjectID `json:"node_ids,omitempty" bson:"-"` NodeIds []primitive.ObjectID `json:"node_ids,omitempty" bson:"-"`
Versions []string `json:"versions,omitempty" bson:"-"` Versions []string `json:"versions,omitempty" bson:"-"`
} }

View File

@@ -3,10 +3,9 @@ package models
type DependencyConfig struct { type DependencyConfig struct {
any `collection:"dependency_configs"` any `collection:"dependency_configs"`
BaseModel[DependencyConfig] `bson:",inline"` BaseModel[DependencyConfig] `bson:",inline"`
Key string `json:"key" bson:"key"` Key string `json:"key" bson:"key"`
Name string `json:"name" bson:"name"` Name string `json:"name" bson:"name"`
Cmd string `json:"cmd" bson:"cmd"` ExecCmd string `json:"exec_cmd" bson:"exec_cmd"`
Proxy string `json:"proxy" bson:"proxy"` PkgCmd string `json:"pkg_cmd" bson:"pkg_cmd"`
SetupNodeIds []string `json:"setup_node_ids" bson:"setup_node_ids"` Proxy string `json:"proxy" bson:"proxy"`
SetupScriptPath string `json:"setup_script_path" bson:"setup_script_path"`
} }

View File

@@ -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"`
}

View File

@@ -5,6 +5,6 @@ import "go.mongodb.org/mongo-driver/bson/primitive"
type DependencyLog struct { type DependencyLog struct {
any `collection:"dependency_logs"` any `collection:"dependency_logs"`
BaseModel[DependencyLog] `bson:",inline"` 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"` Content string `json:"content" bson:"content"`
} }

View File

@@ -10,24 +10,25 @@ import (
) )
const ( const (
DefaultWorkspace = "crawlab_workspace" DefaultWorkspace = "crawlab_workspace"
DefaultTaskLogPath = "/var/log/crawlab/tasks" DefaultTaskLogPath = "/var/log/crawlab/tasks"
DefaultServerHost = "0.0.0.0" DefaultServerHost = "0.0.0.0"
DefaultServerPort = 8000 DefaultServerPort = 8000
DefaultGrpcHost = "localhost" DefaultGrpcHost = "localhost"
DefaultGrpcPort = 9666 DefaultGrpcPort = 9666
DefaultGrpcServerHost = "0.0.0.0" DefaultGrpcServerHost = "0.0.0.0"
DefaultGrpcServerPort = 9666 DefaultGrpcServerPort = 9666
DefaultAuthKey = "Crawlab2024!" DefaultAuthKey = "Crawlab2024!"
DefaultApiEndpoint = "http://localhost:8000" DefaultApiEndpoint = "http://localhost:8000"
DefaultApiAllowOrigin = "*" DefaultApiAllowOrigin = "*"
DefaultApiAllowCredentials = "true" DefaultApiAllowCredentials = "true"
DefaultApiAllowMethods = "DELETE, POST, OPTIONS, GET, PUT" DefaultApiAllowMethods = "DELETE, POST, OPTIONS, GET, PUT"
DefaultApiAllowHeaders = "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With" DefaultApiAllowHeaders = "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With"
DefaultNodeMaxRunners = 0 // 0 means no limit DefaultNodeMaxRunners = 0 // 0 means no limit
MetadataConfigDirName = ".crawlab" DefaultDependencySetupScriptRoot = "/app/install"
MetadataConfigName = "config.json" MetadataConfigDirName = ".crawlab"
PyenvRoot = "/root/.pyenv" MetadataConfigName = "config.json"
PyenvRoot = "/root/.pyenv"
) )
func IsDev() bool { func IsDev() bool {
@@ -221,3 +222,10 @@ func GetMetadataConfigPath() string {
return filepath.Join(homeDirPath, MetadataConfigDirName, MetadataConfigName) return filepath.Join(homeDirPath, MetadataConfigDirName, MetadataConfigName)
} }
func GetDependencySetupScriptRoot() string {
if res := viper.GetString("dependency.setupScriptRoot"); res != "" {
return res
}
return DefaultDependencySetupScriptRoot
}

View File

@@ -313,8 +313,8 @@ type DependencyServiceUpdateLogsRequest struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
DependencyId string `protobuf:"bytes,1,opt,name=dependency_id,json=dependencyId,proto3" json:"dependency_id,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"` Logs []string `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"`
} }
func (x *DependencyServiceUpdateLogsRequest) Reset() { func (x *DependencyServiceUpdateLogsRequest) Reset() {
@@ -349,9 +349,9 @@ func (*DependencyServiceUpdateLogsRequest) Descriptor() ([]byte, []int) {
return file_services_dependency_service_proto_rawDescGZIP(), []int{4} return file_services_dependency_service_proto_rawDescGZIP(), []int{4}
} }
func (x *DependencyServiceUpdateLogsRequest) GetDependencyId() string { func (x *DependencyServiceUpdateLogsRequest) GetTargetId() string {
if x != nil { if x != nil {
return x.DependencyId return x.TargetId
} }
return "" return ""
} }
@@ -363,6 +363,77 @@ func (x *DependencyServiceUpdateLogsRequest) GetLogs() []string {
return nil 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 protoreflect.FileDescriptor
var file_services_dependency_service_proto_rawDesc = []byte{ 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, 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, 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, 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, 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, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67,
0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x61, 0x72,
0x0c, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20,
0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x86, 0x01, 0x0a, 0x27, 0x44, 0x65,
0x73, 0x2a, 0x48, 0x0a, 0x15, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x53, 0x59, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x65, 0x74, 0x75, 0x70, 0x52, 0x65,
0x4e, 0x43, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6b, 0x65,
0x01, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x49, 0x4e, 0x53, 0x54, 0x41, 0x4c, 0x4c, 0x10, 0x02, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x6f, 0x64, 0x65, 0x4b, 0x65, 0x79,
0x12, 0x09, 0x0a, 0x05, 0x53, 0x45, 0x54, 0x55, 0x50, 0x10, 0x03, 0x32, 0xfb, 0x01, 0x0a, 0x11, 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, 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, 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, 0x72, 0x76, 0x69, 0x63, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52,
0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65,
0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x6e, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x52, 0x0a, 0x0f, 0x53, 0x79,
0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x65, 0x74, 0x75, 0x70, 0x12, 0x2d, 0x2e,
0x3c, 0x0a, 0x04, 0x53, 0x79, 0x6e, 0x63, 0x12, 0x22, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53,
0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x53, 0x79, 0x6e, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67, 0x72, 0x53, 0x65, 0x74, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x67,
0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x08,
0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x28, 0x2e, 0x67, 0x72, 0x5a, 0x06, 0x2e, 0x3b, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
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,
} }
var ( 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_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{ var file_services_dependency_service_proto_goTypes = []any{
(DependencyServiceCode)(0), // 0: grpc.DependencyServiceCode (DependencyServiceCode)(0), // 0: grpc.DependencyServiceCode
(*Dependency)(nil), // 1: grpc.Dependency (*Dependency)(nil), // 1: grpc.Dependency
(*DependencyServiceConnectRequest)(nil), // 2: grpc.DependencyServiceConnectRequest (*DependencyServiceConnectRequest)(nil), // 2: grpc.DependencyServiceConnectRequest
(*DependencyServiceConnectResponse)(nil), // 3: grpc.DependencyServiceConnectResponse (*DependencyServiceConnectResponse)(nil), // 3: grpc.DependencyServiceConnectResponse
(*DependencyServiceSyncRequest)(nil), // 4: grpc.DependencyServiceSyncRequest (*DependencyServiceSyncRequest)(nil), // 4: grpc.DependencyServiceSyncRequest
(*DependencyServiceUpdateLogsRequest)(nil), // 5: grpc.DependencyServiceUpdateLogsRequest (*DependencyServiceUpdateLogsRequest)(nil), // 5: grpc.DependencyServiceUpdateLogsRequest
(*Response)(nil), // 6: grpc.Response (*DependencyServiceSyncConfigSetupRequest)(nil), // 6: grpc.DependencyServiceSyncConfigSetupRequest
(*Response)(nil), // 7: grpc.Response
} }
var file_services_dependency_service_proto_depIdxs = []int32{ var file_services_dependency_service_proto_depIdxs = []int32{
0, // 0: grpc.DependencyServiceConnectResponse.code:type_name -> grpc.DependencyServiceCode 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 2, // 3: grpc.DependencyService.Connect:input_type -> grpc.DependencyServiceConnectRequest
4, // 4: grpc.DependencyService.Sync:input_type -> grpc.DependencyServiceSyncRequest 4, // 4: grpc.DependencyService.Sync:input_type -> grpc.DependencyServiceSyncRequest
5, // 5: grpc.DependencyService.UpdateLogs:input_type -> grpc.DependencyServiceUpdateLogsRequest 5, // 5: grpc.DependencyService.UpdateLogs:input_type -> grpc.DependencyServiceUpdateLogsRequest
3, // 6: grpc.DependencyService.Connect:output_type -> grpc.DependencyServiceConnectResponse 6, // 6: grpc.DependencyService.SyncConfigSetup:input_type -> grpc.DependencyServiceSyncConfigSetupRequest
6, // 7: grpc.DependencyService.Sync:output_type -> grpc.Response 3, // 7: grpc.DependencyService.Connect:output_type -> grpc.DependencyServiceConnectResponse
6, // 8: grpc.DependencyService.UpdateLogs:output_type -> grpc.Response 7, // 8: grpc.DependencyService.Sync:output_type -> grpc.Response
6, // [6:9] is the sub-list for method output_type 7, // 9: grpc.DependencyService.UpdateLogs:output_type -> grpc.Response
3, // [3:6] is the sub-list for method input_type 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 type_name
3, // [3:3] is the sub-list for extension extendee 3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name 0, // [0:3] is the sub-list for field type_name
@@ -534,6 +621,18 @@ func file_services_dependency_service_proto_init() {
return nil 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{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@@ -541,7 +640,7 @@ func file_services_dependency_service_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_services_dependency_service_proto_rawDesc, RawDescriptor: file_services_dependency_service_proto_rawDesc,
NumEnums: 1, NumEnums: 1,
NumMessages: 5, NumMessages: 6,
NumExtensions: 0, NumExtensions: 0,
NumServices: 1, NumServices: 1,
}, },

View File

@@ -19,9 +19,10 @@ import (
const _ = grpc.SupportPackageIsVersion8 const _ = grpc.SupportPackageIsVersion8
const ( const (
DependencyService_Connect_FullMethodName = "/grpc.DependencyService/Connect" DependencyService_Connect_FullMethodName = "/grpc.DependencyService/Connect"
DependencyService_Sync_FullMethodName = "/grpc.DependencyService/Sync" DependencyService_Sync_FullMethodName = "/grpc.DependencyService/Sync"
DependencyService_UpdateLogs_FullMethodName = "/grpc.DependencyService/UpdateLogs" DependencyService_UpdateLogs_FullMethodName = "/grpc.DependencyService/UpdateLogs"
DependencyService_SyncConfigSetup_FullMethodName = "/grpc.DependencyService/SyncConfigSetup"
) )
// DependencyServiceClient is the client API for DependencyService service. // 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) Connect(ctx context.Context, in *DependencyServiceConnectRequest, opts ...grpc.CallOption) (DependencyService_ConnectClient, error)
Sync(ctx context.Context, in *DependencyServiceSyncRequest, opts ...grpc.CallOption) (*Response, error) Sync(ctx context.Context, in *DependencyServiceSyncRequest, opts ...grpc.CallOption) (*Response, error)
UpdateLogs(ctx context.Context, opts ...grpc.CallOption) (DependencyService_UpdateLogsClient, 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 { type dependencyServiceClient struct {
@@ -119,6 +121,16 @@ func (x *dependencyServiceUpdateLogsClient) CloseAndRecv() (*Response, error) {
return m, nil 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. // DependencyServiceServer is the server API for DependencyService service.
// All implementations must embed UnimplementedDependencyServiceServer // All implementations must embed UnimplementedDependencyServiceServer
// for forward compatibility // for forward compatibility
@@ -126,6 +138,7 @@ type DependencyServiceServer interface {
Connect(*DependencyServiceConnectRequest, DependencyService_ConnectServer) error Connect(*DependencyServiceConnectRequest, DependencyService_ConnectServer) error
Sync(context.Context, *DependencyServiceSyncRequest) (*Response, error) Sync(context.Context, *DependencyServiceSyncRequest) (*Response, error)
UpdateLogs(DependencyService_UpdateLogsServer) error UpdateLogs(DependencyService_UpdateLogsServer) error
SyncConfigSetup(context.Context, *DependencyServiceSyncConfigSetupRequest) (*Response, error)
mustEmbedUnimplementedDependencyServiceServer() mustEmbedUnimplementedDependencyServiceServer()
} }
@@ -142,6 +155,9 @@ func (UnimplementedDependencyServiceServer) Sync(context.Context, *DependencySer
func (UnimplementedDependencyServiceServer) UpdateLogs(DependencyService_UpdateLogsServer) error { func (UnimplementedDependencyServiceServer) UpdateLogs(DependencyService_UpdateLogsServer) error {
return status.Errorf(codes.Unimplemented, "method UpdateLogs not implemented") 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() {} func (UnimplementedDependencyServiceServer) mustEmbedUnimplementedDependencyServiceServer() {}
// UnsafeDependencyServiceServer may be embedded to opt out of forward compatibility for this service. // 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 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. // DependencyService_ServiceDesc is the grpc.ServiceDesc for DependencyService service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@@ -231,6 +265,10 @@ var DependencyService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Sync", MethodName: "Sync",
Handler: _DependencyService_Sync_Handler, Handler: _DependencyService_Sync_Handler,
}, },
{
MethodName: "SyncConfigSetup",
Handler: _DependencyService_SyncConfigSetup_Handler,
},
}, },
Streams: []grpc.StreamDesc{ Streams: []grpc.StreamDesc{
{ {

View File

@@ -35,12 +35,20 @@ message DependencyServiceSyncRequest {
} }
message DependencyServiceUpdateLogsRequest { message DependencyServiceUpdateLogsRequest {
string dependency_id = 1; string target_id = 1;
repeated string logs = 2; repeated string logs = 2;
} }
message DependencyServiceSyncConfigSetupRequest {
string node_key = 1;
string lang = 2;
string status = 3;
string error = 4;
}
service DependencyService { service DependencyService {
rpc Connect(DependencyServiceConnectRequest) returns (stream DependencyServiceConnectResponse){}; rpc Connect(DependencyServiceConnectRequest) returns (stream DependencyServiceConnectResponse){};
rpc Sync(DependencyServiceSyncRequest) returns (Response){}; rpc Sync(DependencyServiceSyncRequest) returns (Response){};
rpc UpdateLogs(stream DependencyServiceUpdateLogsRequest) returns (Response){}; rpc UpdateLogs(stream DependencyServiceUpdateLogsRequest) returns (Response){};
rpc SyncConfigSetup(DependencyServiceSyncConfigSetupRequest) returns (Response){};
} }