Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Job Queues
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Services
Job Queues
Commits
51d60bd0
Verified
Commit
51d60bd0
authored
11 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
feat: new manager function saveJob
parent
268f02f0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
manager.go
+19
-3
19 additions, 3 deletions
manager.go
scheduler.go
+0
-95
0 additions, 95 deletions
scheduler.go
with
19 additions
and
98 deletions
manager.go
+
19
−
3
View file @
51d60bd0
...
...
@@ -306,6 +306,25 @@ func (m *Manager) removeJobInternal(id JobID) error {
}
// SaveJob saves a job to the database
func
(
m
*
Manager
)
SaveJob
(
job
GenericJob
)
error
{
if
m
==
nil
{
return
ErrManagerNotInitialized
}
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
if
m
.
jobSyncer
!=
nil
{
return
m
.
jobSyncer
.
SaveJob
(
job
)
}
return
nil
}
// UpdateJob updates a job in the database
func
(
m
*
Manager
)
UpdateJob
(
job
GenericJob
)
error
{
if
m
==
nil
{
...
...
@@ -690,7 +709,6 @@ func (m *Manager) handleJobEvents() {
err
:=
m
.
queue
.
Enqueue
(
job
)
if
err
!=
nil
&&
!
errors
.
Is
(
err
,
ErrJobAlreadyExists
)
{
Error
(
"Error while queueing job"
,
"error"
,
err
)
}
case
JobReady
:
...
...
@@ -733,9 +751,7 @@ func (m *Manager) handleJobEvents() {
eventBus
:=
m
.
GetEventBus
()
eventBus
.
Publish
(
JobFinished
,
nextJob
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
scheduler.go
+
0
−
95
View file @
51d60bd0
...
...
@@ -146,10 +146,6 @@ func (sp *SchedulerPersistence) UnmarshalYAML(unmarshal func(interface{}) error)
type
Alias
SchedulerPersistence
aux
:=
&
struct
{
*
Alias
`yaml:",inline"`
//TimeString *string `yaml:"time,omitempty"`
//IntervalString *string `yaml:"interval,omitempty"`
//DelayString *string `yaml:"delay,omitempty"`
//EventFlagsString *string `yaml:"eventFlags,omitempty"`
}{
Alias
:
(
*
Alias
)(
sp
),
}
...
...
@@ -161,7 +157,6 @@ func (sp *SchedulerPersistence) UnmarshalYAML(unmarshal func(interface{}) error)
if
err
!=
nil
{
return
err
}
sp
.
Time
=
&
t
}
...
...
@@ -206,93 +201,3 @@ func (sp *SchedulerPersistence) UnmarshalYAML(unmarshal func(interface{}) error)
}
return
nil
}
//type scheduleImportStruct struct {
// Time *string `yaml:"time,omitempty" json:"time,omitempty"`
// Interval *string `yaml:"interval,omitempty" json:"interval,omitempty"`
// Delay *string `yaml:"delay,omitempty" json:"delay,omitempty"`
// EventFlags *string `yaml:"eventFlags,omitempty" json:"eventFlags,omitempty"`
//
// Type string `yaml:"type" json:"type"`
// Spec string `yaml:"spec,omitempty" json:"spec,omitempty"`
// Event string `yaml:"event,omitempty" json:"event,omitempty"`
// Executed bool `yaml:"executed,omitempty" json:"executed,omitempty"`
// Path string `yaml:"path,omitempty" json:"path,omitempty"`
//}
//
//func (sp *SchedulerPersistence) parseAndAssignFields(aux scheduleImportStruct) error {
//
// sp.Type = aux.Type
// sp.Spec = aux.Spec
// sp.Event = EventName(aux.Event)
// sp.Executed = aux.Executed
// sp.Path = aux.Path
//
// if aux.Time != nil && *aux.Time != "" {
// var t time.Time
// var err error
// for _, format := range SupportedTimeFormats {
// t, err = time.Parse(format, *aux.Time)
// if err == nil {
// break
// }
// }
// if err != nil {
// return err
// }
// sp.Time = &t
// }
//
// if aux.Interval != nil && *aux.Interval != "" {
// d, err := time.ParseDuration(*aux.Interval)
// if err != nil {
// return err
// }
// sp.Interval = d
// }
//
// if aux.Delay != nil && *aux.Delay != "" {
// d, err := time.ParseDuration(*aux.Delay)
// if err != nil {
// return err
// }
// sp.Delay = d
// }
//
// if aux.EventFlags != nil && *aux.EventFlags != "" {
// sp.EventFlags = fsnotify.Op(0)
// for _, flag := range strings.Split(*aux.EventFlags, "|") {
// switch flag {
// case "Create":
// sp.EventFlags |= fsnotify.Create
// case "Write":
// sp.EventFlags |= fsnotify.Write
// case "Remove":
// sp.EventFlags |= fsnotify.Remove
// case "Rename":
// sp.EventFlags |= fsnotify.Rename
// case "Chmod":
// sp.EventFlags |= fsnotify.Chmod
// }
// }
// }
//
// return nil
//}
//// UnmarshalJSON implements the json.Unmarshaler interface
//func (sp *SchedulerPersistence) UnmarshalJSON(data []byte) error {
// var aux scheduleImportStruct
// if err := json.Unmarshal(data, &aux); err != nil {
// return err
// }
// return sp.parseAndAssignFields(aux)
//}
//
//func (sp *SchedulerPersistence) UnmarshalYAML(unmarshal func(interface{}) error) error {
// var aux scheduleImportStruct
// if err := unmarshal(&aux); err != nil {
// return err
// }
// return sp.parseAndAssignFields(aux)
//}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment