Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • oss/libraries/go/services/job-queues
1 result
Select Git revision
Show changes
Commits on Source (1)
...@@ -6,20 +6,20 @@ import ( ...@@ -6,20 +6,20 @@ import (
) )
type JobLog struct { type JobLog struct {
LogID uint `gorm:"primarykey;autoIncrement:true" json:"log_id"` LogID uint `gorm:"primarykey;autoIncrement:true" json:"logId"`
JobID JobID `json:"job_id" gorm:"type:varchar(255);foreignKey:JobID;references:ID"` JobID JobID `json:"jobId" gorm:"type:varchar(255);foreignKey:JobID;references:ID"`
ProcessID int `json:"process_id"` ProcessID int `json:"processId"`
StartTime time.Time `json:"start_time"` StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"end_time"` EndTime time.Time `json:"endTime"`
ExitCode int `json:"exit_code"` ExitCode int `json:"exitCode"`
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_usage" gorm:"embedded;embeddedPrefix:resource_usage_"` ResourceUsage ResourceUsage `json:"resourceUsage" 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_msg"` ErrorMsg string `json:"errorMsg"`
IsSuccessful bool `json:"is_successful"` IsSuccessful bool `json:"isSuccessful"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at" yaml:"created_at"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt" yaml:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at" yaml:"updated_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt" yaml:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-" yaml:"-"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-" yaml:"-"`
} }
......
...@@ -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_id" gorm:"primaryKey"` JobID JobID `json:"jobId" gorm:"primaryKey"`
RunCount int `json:"run_count"` RunCount int `json:"runCount"`
SuccessCount int `json:"success_count"` SuccessCount int `json:"successCount"`
ErrorCount int `json:"error_count"` ErrorCount int `json:"errorCount"`
TimeMetrics TimeMetrics `json:"time_metrics" gorm:"embedded;embeddedPrefix:time_metrics_"` TimeMetrics TimeMetrics `json:"timeMetrics" gorm:"embedded;embeddedPrefix:time_metrics_"`
CreatedAt time.Time `gorm:"column:created_at" json:"created_at" yaml:"created_at"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt" yaml:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at" yaml:"updated_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt" yaml:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-" yaml:"-"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-" yaml:"-"`
} }
......
...@@ -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()
......
...@@ -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_at" yaml:"created_at"` CreatedAt time.Time `gorm:"column:created_at" json:"createdAt" yaml:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at" yaml:"updated_at"` UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt" yaml:"updatedAt"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-" yaml:"-"` DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"-" yaml:"-"`
} }
......