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
Compare revisions
v1.13.2 to v1.14.0
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
oss/libraries/go/services/job-queues
Select target project
No results found
v1.14.0
Select Git revision
Swap
Target
oss/libraries/go/services/job-queues
Select target project
oss/libraries/go/services/job-queues
1 result
v1.13.2
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
feat: new runJob method
#32
· 9d774f0a
Volker Schukai
authored
1 year ago
9d774f0a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
job-log.go
+11
-11
11 additions, 11 deletions
job-log.go
job-stat.go
+7
-7
7 additions, 7 deletions
job-stat.go
manager.go
+18
-0
18 additions, 0 deletions
manager.go
persistence.go
+2
-2
2 additions, 2 deletions
persistence.go
with
38 additions
and
20 deletions
job-log.go
View file @
9d774f0a
...
@@ -6,20 +6,20 @@ import (
...
@@ -6,20 +6,20 @@ import (
)
)
type
JobLog
struct
{
type
JobLog
struct
{
LogID
uint
`gorm:"primarykey;autoIncrement:true" json:"log
_i
d"`
LogID
uint
`gorm:"primarykey;autoIncrement:true" json:"log
I
d"`
JobID
JobID
`json:"job
_i
d" gorm:"type:varchar(255);foreignKey:JobID;references:ID"`
JobID
JobID
`json:"job
I
d" gorm:"type:varchar(255);foreignKey:JobID;references:ID"`
ProcessID
int
`json:"process
_i
d"`
ProcessID
int
`json:"process
I
d"`
StartTime
time
.
Time
`json:"start
_t
ime"`
StartTime
time
.
Time
`json:"start
T
ime"`
EndTime
time
.
Time
`json:"end
_t
ime"`
EndTime
time
.
Time
`json:"end
T
ime"`
ExitCode
int
`json:"exit
_c
ode"`
ExitCode
int
`json:"exit
C
ode"`
Result
string
`json:"output" gorm:"type:TEXT"`
// Assuming serialized JSON for any type
Result
string
`json:"output" gorm:"type:TEXT"`
// Assuming serialized JSON for any type
ResourceUsage
ResourceUsage
`json:"resource
_u
sage" gorm:"embedded;embeddedPrefix:resource_usage_"`
ResourceUsage
ResourceUsage
`json:"resource
U
sage" gorm:"embedded;embeddedPrefix:resource_usage_"`
IO
IO
`json:"io" gorm:"embedded;embeddedPrefix:io_"`
IO
IO
`json:"io" gorm:"embedded;embeddedPrefix:io_"`
ErrorMsg
string
`json:"error
_m
sg"`
ErrorMsg
string
`json:"error
M
sg"`
IsSuccessful
bool
`json:"is
_s
uccessful"`
IsSuccessful
bool
`json:"is
S
uccessful"`
CreatedAt
time
.
Time
`gorm:"column:created_at" json:"created
_a
t" yaml:"created
_a
t"`
CreatedAt
time
.
Time
`gorm:"column:created_at" json:"created
A
t" yaml:"created
A
t"`
UpdatedAt
time
.
Time
`gorm:"column:updated_at" json:"updated
_a
t" yaml:"updated
_a
t"`
UpdatedAt
time
.
Time
`gorm:"column:updated_at" json:"updated
A
t" yaml:"updated
A
t"`
DeletedAt
gorm
.
DeletedAt
`gorm:"column:deleted_at;index" json:"-" yaml:"-"`
DeletedAt
gorm
.
DeletedAt
`gorm:"column:deleted_at;index" json:"-" yaml:"-"`
}
}
...
...
This diff is collapsed.
Click to expand it.
job-stat.go
View file @
9d774f0a
...
@@ -7,14 +7,14 @@ import (
...
@@ -7,14 +7,14 @@ import (
// important: if you want to add fields to this struct, you have to add them to the ResetStats() method as well
// important: if you want to add fields to this struct, you have to add them to the ResetStats() method as well
type
JobStats
struct
{
type
JobStats
struct
{
JobID
JobID
`json:"job
_i
d" gorm:"primaryKey"`
JobID
JobID
`json:"job
I
d" gorm:"primaryKey"`
RunCount
int
`json:"run
_c
ount"`
RunCount
int
`json:"run
C
ount"`
SuccessCount
int
`json:"success
_c
ount"`
SuccessCount
int
`json:"success
C
ount"`
ErrorCount
int
`json:"error
_c
ount"`
ErrorCount
int
`json:"error
C
ount"`
TimeMetrics
TimeMetrics
`json:"time
_m
etrics" gorm:"embedded;embeddedPrefix:time_metrics_"`
TimeMetrics
TimeMetrics
`json:"time
M
etrics" gorm:"embedded;embeddedPrefix:time_metrics_"`
CreatedAt
time
.
Time
`gorm:"column:created_at" json:"created
_a
t" yaml:"created
_a
t"`
CreatedAt
time
.
Time
`gorm:"column:created_at" json:"created
A
t" yaml:"created
A
t"`
UpdatedAt
time
.
Time
`gorm:"column:updated_at" json:"updated
_a
t" yaml:"updated
_a
t"`
UpdatedAt
time
.
Time
`gorm:"column:updated_at" json:"updated
A
t" yaml:"updated
A
t"`
DeletedAt
gorm
.
DeletedAt
`gorm:"column:deleted_at;index" json:"-" yaml:"-"`
DeletedAt
gorm
.
DeletedAt
`gorm:"column:deleted_at;index" json:"-" yaml:"-"`
}
}
...
...
This diff is collapsed.
Click to expand it.
manager.go
View file @
9d774f0a
...
@@ -481,12 +481,30 @@ func (m *Manager) SetLogger(logger Logger) *Manager {
...
@@ -481,12 +481,30 @@ func (m *Manager) SetLogger(logger Logger) *Manager {
return
m
return
m
}
}
// GetLogger returns the logger
func
(
m
*
Manager
)
GetLogger
()
Logger
{
func
(
m
*
Manager
)
GetLogger
()
Logger
{
m
.
mu
.
Lock
()
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
defer
m
.
mu
.
Unlock
()
return
m
.
logger
return
m
.
logger
}
}
// RunJob runs a job immediately and does not schedule it
func
(
m
*
Manager
)
RunJob
(
job
GenericJob
)
error
{
m
.
mu
.
Lock
()
defer
m
.
mu
.
Unlock
()
if
m
.
state
!=
ManagerStateRunning
{
return
ErrManagerNotRunning
}
if
!
job
.
IsPaused
()
{
m
.
eventBus
.
Publish
(
QueueJob
,
job
)
}
return
nil
}
// ScheduleJob schedules a job
// ScheduleJob schedules a job
func
(
m
*
Manager
)
ScheduleJob
(
job
GenericJob
,
scheduler
Scheduler
)
error
{
func
(
m
*
Manager
)
ScheduleJob
(
job
GenericJob
,
scheduler
Scheduler
)
error
{
m
.
mu
.
Lock
()
m
.
mu
.
Lock
()
...
...
This diff is collapsed.
Click to expand it.
persistence.go
View file @
9d774f0a
...
@@ -30,8 +30,8 @@ type JobPersistence struct {
...
@@ -30,8 +30,8 @@ type JobPersistence struct {
Logs
[]
JobLog
`gorm:"foreignKey:JobID;references:ID" json:"-" yaml:"-"`
Logs
[]
JobLog
`gorm:"foreignKey:JobID;references:ID" json:"-" yaml:"-"`
Stats
JobStats
`gorm:"foreignKey:JobID" json:"stats" yaml:"stats"`
Stats
JobStats
`gorm:"foreignKey:JobID" json:"stats" yaml:"stats"`
CreatedAt
time
.
Time
`gorm:"column:created_at" json:"created
_a
t" yaml:"created
_a
t"`
CreatedAt
time
.
Time
`gorm:"column:created_at" json:"created
A
t" yaml:"created
A
t"`
UpdatedAt
time
.
Time
`gorm:"column:updated_at" json:"updated
_a
t" yaml:"updated
_a
t"`
UpdatedAt
time
.
Time
`gorm:"column:updated_at" json:"updated
A
t" yaml:"updated
A
t"`
DeletedAt
gorm
.
DeletedAt
`gorm:"column:deleted_at;index" json:"-" yaml:"-"`
DeletedAt
gorm
.
DeletedAt
`gorm:"column:deleted_at;index" json:"-" yaml:"-"`
}
}
...
...
This diff is collapsed.
Click to expand it.