update
This commit is contained in:
@@ -24,7 +24,7 @@ type ScheduledExecution struct {
|
||||
func (sb *ScheduledExecution) DeleteSchedules(uuid string) {
|
||||
Executions.Mu.Lock()
|
||||
defer Executions.Mu.Unlock()
|
||||
delete(sb.Execs,uuid)
|
||||
delete(sb.Execs, uuid)
|
||||
}
|
||||
|
||||
func (sb *ScheduledExecution) AddSchedules(new_executions []*workflow_execution.WorkflowExecution, logger zerolog.Logger) {
|
||||
@@ -39,10 +39,10 @@ func (sb *ScheduledExecution) AddSchedules(new_executions []*workflow_execution.
|
||||
}
|
||||
|
||||
func (sb *ScheduledExecution) execIsSet(exec *workflow_execution.WorkflowExecution) bool {
|
||||
if _, ok := sb.Execs[exec.UUID]; ok{
|
||||
if _, ok := sb.Execs[exec.UUID]; ok {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
@@ -58,18 +58,21 @@ type ScheduleManager struct {
|
||||
// on workflows' scheduling. Messages must contain
|
||||
// workflow execution ID, to allow retrieval of execution infos
|
||||
func (s *ScheduleManager) ListenNATS() {
|
||||
nc, err := nats.Connect(oclib.GetConfig().NATSUrl)
|
||||
if err != nil {
|
||||
s.Logger.Error().Msg("Could not connect to NATS")
|
||||
return
|
||||
for {
|
||||
nc, err := nats.Connect(oclib.GetConfig().NATSUrl)
|
||||
if err != nil {
|
||||
s.Logger.Error().Msg("Could not connect to NATS")
|
||||
time.Sleep(10 * time.Second)
|
||||
continue
|
||||
}
|
||||
defer nc.Close()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go s.listenForChange(nc, tools.REMOVE.GenerateKey(oclib.WORKFLOW.String()), true, wg)
|
||||
go s.listenForChange(nc, tools.CREATE.GenerateKey(oclib.WORKFLOW.String()), false, wg)
|
||||
wg.Wait()
|
||||
break
|
||||
}
|
||||
defer nc.Close()
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go s.listenForChange(nc, tools.REMOVE.GenerateKey(oclib.WORKFLOW.String()), true, wg)
|
||||
go s.listenForChange(nc, tools.CREATE.GenerateKey(oclib.WORKFLOW.String()), false, wg)
|
||||
wg.Wait()
|
||||
|
||||
}
|
||||
|
||||
// Goroutine listening to a NATS server for updates
|
||||
@@ -121,7 +124,7 @@ func (s *ScheduleManager) getExecution(from time.Time, to time.Time) (exec_list
|
||||
}
|
||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.WORKFLOW_EXECUTION), "", "", []string{}, nil).Search(&f, "", false)
|
||||
if res.Code != 200 {
|
||||
s.Logger.Error().Msg("Error loading")
|
||||
s.Logger.Error().Msg("Error loading " + res.Err)
|
||||
return
|
||||
}
|
||||
for _, exec := range res.Data {
|
||||
|
||||
Reference in New Issue
Block a user