Skip to content

Commit

Permalink
ScheduleDelayMinutes name change
Browse files Browse the repository at this point in the history
  • Loading branch information
schowsf committed Aug 21, 2023
1 parent acc976f commit bcbdec5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
18 changes: 9 additions & 9 deletions database/table/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (

type Workflow struct {
gorm.Model
Name string `gorm:"type:varchar(256);not null;index:workflows_name,unique"`
Artifact string `gorm:"type:varchar(2048);not null"`
Command string `gorm:"type:text;not null"`
Every model.Every `gorm:"type:varchar(64);not null"`
NextRuntime time.Time `gorm:"not null"`
Backfill bool `gorm:"not null"`
Owner *string `gorm:"type:varchar(2048)"`
IsActive bool `gorm:"not null"`
StaggerStartMinutes uint `gorm:"default:0"`
Name string `gorm:"type:varchar(256);not null;index:workflows_name,unique"`
Artifact string `gorm:"type:varchar(2048);not null"`
Command string `gorm:"type:text;not null"`
Every model.Every `gorm:"type:varchar(64);not null"`
NextRuntime time.Time `gorm:"not null"`
Backfill bool `gorm:"not null"`
Owner *string `gorm:"type:varchar(2048)"`
IsActive bool `gorm:"not null"`
ScheduleDelayMinutes uint `gorm:"default:0"`

ScheduledWorkflows []ScheduledWorkflow
}
Expand Down
36 changes: 18 additions & 18 deletions service/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ type Control struct {
}

type postWorkflowReq struct {
Name string `json:"name" binding:"required"`
Artifact string `json:"artifact" binding:"required"`
Command string `json:"command" binding:"required"`
Every string `json:"every" binding:"required"`
NextRuntime time.Time `json:"nextRuntime" binding:"required"`
Backfill bool `json:"backfill"` // default false if absent
Owner *string `json:"owner"`
IsActive bool `json:"isActive"` // default false if absent
StaggerStartMinutes uint `json:"staggerStartMinutes"`
Name string `json:"name" binding:"required"`
Artifact string `json:"artifact" binding:"required"`
Command string `json:"command" binding:"required"`
Every string `json:"every" binding:"required"`
NextRuntime time.Time `json:"nextRuntime" binding:"required"`
Backfill bool `json:"backfill"` // default false if absent
Owner *string `json:"owner"`
IsActive bool `json:"isActive"` // default false if absent
ScheduleDelayMinutes uint `json:"scheduleDelayMinutes"`
}

type deleteWorkflowReq struct {
Expand Down Expand Up @@ -69,15 +69,15 @@ func (ctrl *Control) putWorkflow(c *gin.Context) {
}

wf := table.Workflow{
Name: body.Name,
Artifact: body.Artifact,
Command: body.Command,
Every: every,
NextRuntime: body.NextRuntime,
Backfill: body.Backfill,
Owner: body.Owner,
IsActive: body.IsActive,
StaggerStartMinutes: body.StaggerStartMinutes,
Name: body.Name,
Artifact: body.Artifact,
Command: body.Command,
Every: every,
NextRuntime: body.NextRuntime,
Backfill: body.Backfill,
Owner: body.Owner,
IsActive: body.IsActive,
ScheduleDelayMinutes: body.ScheduleDelayMinutes,
}
// upsert workflow
ctrl.db.Clauses(
Expand Down
8 changes: 4 additions & 4 deletions service/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ func (s *Scheduler) lockAndCreate(db *gorm.DB, wf table.Workflow) {

scheduleStatus := s.createWorkflow(client, wf)

var staggerStartMinutes uint = 0
if wf.StaggerStartMinutes != 0 {
staggerStartMinutes = wf.StaggerStartMinutes
var scheduleDelayMinutes uint = 0
if wf.ScheduleDelayMinutes != 0 {
scheduleDelayMinutes = wf.ScheduleDelayMinutes
}

// add to scheduled and update the next run time
Expand All @@ -217,7 +217,7 @@ func (s *Scheduler) lockAndCreate(db *gorm.DB, wf table.Workflow) {
}).Error; err != nil {
return err
}
startTime = startTime.Add(time.Duration(staggerStartMinutes) * time.Minute)
startTime = startTime.Add(time.Duration(scheduleDelayMinutes) * time.Minute)
}

fmt.Println(wf.Every)
Expand Down

0 comments on commit bcbdec5

Please sign in to comment.