changed how we store upcoming executions from slice to map
This commit is contained in:
@@ -17,20 +17,14 @@ import (
|
||||
)
|
||||
|
||||
type ScheduledExecution struct {
|
||||
Execs []*workflow_execution.WorkflowExecution
|
||||
Execs map[string]workflow_execution.WorkflowExecution
|
||||
Mu sync.Mutex
|
||||
}
|
||||
|
||||
func (sb *ScheduledExecution) DeleteSchedules(workflow_id string) {
|
||||
toNotDelete := []*workflow_execution.WorkflowExecution{}
|
||||
for _, b := range sb.Execs {
|
||||
if b.WorkflowID != workflow_id {
|
||||
toNotDelete = append(toNotDelete, b)
|
||||
}
|
||||
}
|
||||
func (sb *ScheduledExecution) DeleteSchedules(uuid string) {
|
||||
Executions.Mu.Lock()
|
||||
defer Executions.Mu.Unlock()
|
||||
sb.Execs = toNotDelete
|
||||
delete(sb.Execs,uuid)
|
||||
}
|
||||
|
||||
func (sb *ScheduledExecution) AddSchedules(new_executions []*workflow_execution.WorkflowExecution, logger zerolog.Logger) {
|
||||
@@ -39,17 +33,16 @@ func (sb *ScheduledExecution) AddSchedules(new_executions []*workflow_execution.
|
||||
for _, exec := range new_executions {
|
||||
fmt.Println("Adding "+exec.UUID, !sb.execIsSet(exec))
|
||||
if !sb.execIsSet(exec) {
|
||||
sb.Execs = append(sb.Execs, exec)
|
||||
sb.Execs[exec.UUID] = *exec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (sb *ScheduledExecution) execIsSet(exec *workflow_execution.WorkflowExecution) bool {
|
||||
for _, b := range sb.Execs {
|
||||
if b.Equals(exec) {
|
||||
return true
|
||||
}
|
||||
if _, ok := sb.Execs[exec.UUID]; ok{
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user