feat: updated dependency handler logic

This commit is contained in:
Marvin Zhang
2024-11-05 11:40:12 +08:00
parent e33fcfc150
commit 10bb511c5f
7 changed files with 64 additions and 102 deletions

View File

@@ -30,13 +30,10 @@ func (svr DependencyServiceServer) Connect(req *grpc.DependencyServiceConnectReq
log.Info("[DependencyServiceServer] connected: " + req.NodeKey)
// Keep this scope alive because once this scope exits - the stream is closed
for {
select {
case <-stream.Context().Done():
log.Info("[DependencyServiceServer] disconnected: " + req.NodeKey)
return nil
}
}
<-stream.Context().Done()
log.Info("[DependencyServiceServer] disconnected: " + req.NodeKey)
return nil
}
func (svr DependencyServiceServer) Sync(ctx context.Context, request *grpc.DependencyServiceSyncRequest) (response *grpc.Response, err error) {

View File

@@ -74,7 +74,6 @@ func GetModelInstances() []any {
*new(Dependency),
*new(DependencyLog),
*new(DependencySetting),
*new(DependencyTask),
*new(DependencyRepo),
*new(Environment),
*new(Git),

View File

@@ -1,10 +1,7 @@
package models
import "go.mongodb.org/mongo-driver/bson/primitive"
type DependencyLog struct {
any `collection:"dependency_logs"`
BaseModel[DependencyLog] `bson:",inline"`
TaskId primitive.ObjectID `json:"task_id" bson:"task_id"`
Content string `json:"content" bson:"content"`
Content string `json:"content" bson:"content"`
}

View File

@@ -1,17 +1,12 @@
package models
import (
"time"
)
type DependencySetting struct {
any `collection:"dependency_settings"`
BaseModel[DependencySetting] `bson:",inline"`
Key string `json:"key" bson:"key"`
Name string `json:"name" bson:"name"`
Description string `json:"description" bson:"description"`
Enabled bool `json:"enabled" bson:"enabled"`
Cmd string `json:"cmd" bson:"cmd"`
Proxy string `json:"proxy" bson:"proxy"`
LastUpdateTs time.Time `json:"last_update_ts" bson:"last_update_ts"`
Key string `json:"key" bson:"key"`
Name string `json:"name" bson:"name"`
Description string `json:"description" bson:"description"`
Enabled bool `json:"enabled" bson:"enabled"`
Cmd string `json:"cmd" bson:"cmd"`
Proxy string `json:"proxy" bson:"proxy"`
}

View File

@@ -1,15 +0,0 @@
package models
import "go.mongodb.org/mongo-driver/bson/primitive"
type DependencyTask struct {
any `collection:"dependency_tasks"`
BaseModel[DependencyTask] `bson:",inline"`
Status string `json:"status" bson:"status"`
Error string `json:"error" bson:"error"`
SettingId primitive.ObjectID `json:"setting_id" bson:"setting_id"`
Type string `json:"type" bson:"type"`
NodeId primitive.ObjectID `json:"node_id" bson:"node_id"`
Action string `json:"action" bson:"action"`
DepNames []string `json:"dep_names" bson:"dep_names"`
}