Build up Clean Schedulerd + Lib Kube

This commit is contained in:
mr
2026-02-25 13:19:46 +01:00
parent 142a81197b
commit dbc41f0326
9 changed files with 315 additions and 193 deletions

View File

@@ -9,7 +9,6 @@ import (
oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/dbs"
"cloud.o-forge.io/core/oc-lib/models/common/enum"
"cloud.o-forge.io/core/oc-lib/models/resources"
"cloud.o-forge.io/core/oc-lib/models/workflow_execution"
"cloud.o-forge.io/core/oc-lib/tools"
@@ -25,7 +24,7 @@ type ScheduledExecution struct {
func (sb *ScheduledExecution) DeleteSchedules(resp tools.NATSResponse) {
var m map[string]string
json.Unmarshal(resp.Payload, m)
json.Unmarshal(resp.Payload, &m)
Executions.Mu.Lock()
defer Executions.Mu.Unlock()
delete(sb.Execs, m["id"])
@@ -38,6 +37,9 @@ func (sb *ScheduledExecution) AddSchedules(new_executions []*workflow_execution.
fmt.Println("Adding "+exec.UUID, !sb.execIsSet(exec))
if !sb.execIsSet(exec) {
sb.Execs[exec.UUID] = *exec
oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), nil).UpdateOne(map[string]interface{}{
"state": enum.SCHEDULED.EnumIndex(),
}, exec.GetID())
}
}
}
@@ -91,18 +93,19 @@ func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list
func (s *ScheduleManager) ExecuteWorkflow(resp tools.NATSResponse) {
var m map[string]string
json.Unmarshal(resp.Payload, &m)
res := resources.WorkflowResource{}
access := res.GetAccessor(&tools.APIRequest{})
if d, code, err := access.LoadOne(m["workflow_id"]); code == 200 && err == nil {
access := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW), nil)
if d := access.LoadOne(fmt.Sprintf("%v", m["workflow_id"])); d.Err == "" {
eventExec := &workflow_execution.WorkflowExecution{
WorkflowID: d.GetID(),
WorkflowID: d.Data.GetID(),
ExecDate: time.Now(),
ExecutionsID: uuid.New().String(),
State: enum.SCHEDULED,
}
Executions.AddSchedules([]*workflow_execution.WorkflowExecution{eventExec}, s.Logger)
exec := oclib.NewRequestAdmin(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), nil).StoreOne(eventExec.Serialize(eventExec))
if execc := exec.ToWorkflowExecution(); execc != nil {
Executions.AddSchedules([]*workflow_execution.WorkflowExecution{execc}, s.Logger)
}
}
}
func (s *ScheduleManager) GetNextScheduledWorkflows(_ tools.NATSResponse) {