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
  • master
  • v1.0.0
  • v1.0.1
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.12.0
  • v1.12.1
  • v1.12.2
  • v1.12.3
  • v1.12.4
  • v1.12.5
  • v1.12.6
  • v1.12.7
  • v1.12.8
  • v1.13.0
  • v1.13.1
  • v1.13.2
  • v1.14.0
  • v1.15.0
  • v1.15.1
  • v1.15.10
  • v1.15.11
  • v1.15.12
  • v1.15.13
  • v1.15.14
  • v1.15.15
  • v1.15.16
  • v1.15.17
  • v1.15.2
  • v1.15.3
  • v1.15.4
  • v1.15.5
  • v1.15.6
  • v1.15.7
  • v1.15.8
  • v1.15.9
  • v1.16.0
  • v1.16.1
  • v1.17.0
  • v1.18.0
  • v1.18.1
  • v1.18.2
  • v1.19.0
  • v1.19.1
  • v1.19.2
  • v1.19.3
  • v1.19.4
  • v1.2.0
  • v1.20.0
  • v1.20.1
  • v1.20.2
  • v1.20.3
  • v1.21.0
  • v1.21.1
  • v1.22.0
  • v1.23.0
  • v1.23.1
  • v1.23.2
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.4.0
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.7.0
  • v1.7.1
  • v1.7.2
  • v1.7.3
  • v1.8.0
  • v1.8.1
  • v1.9.0
76 results

Target

Select target project
  • oss/libraries/go/services/job-queues
1 result
Select Git revision
  • master
  • v1.0.0
  • v1.0.1
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.12.0
  • v1.12.1
  • v1.12.2
  • v1.12.3
  • v1.12.4
  • v1.12.5
  • v1.12.6
  • v1.12.7
  • v1.12.8
  • v1.13.0
  • v1.13.1
  • v1.13.2
  • v1.14.0
  • v1.15.0
  • v1.15.1
  • v1.15.10
  • v1.15.11
  • v1.15.12
  • v1.15.13
  • v1.15.14
  • v1.15.15
  • v1.15.16
  • v1.15.17
  • v1.15.2
  • v1.15.3
  • v1.15.4
  • v1.15.5
  • v1.15.6
  • v1.15.7
  • v1.15.8
  • v1.15.9
  • v1.16.0
  • v1.16.1
  • v1.17.0
  • v1.18.0
  • v1.18.1
  • v1.18.2
  • v1.19.0
  • v1.19.1
  • v1.19.2
  • v1.19.3
  • v1.19.4
  • v1.2.0
  • v1.20.0
  • v1.20.1
  • v1.20.2
  • v1.20.3
  • v1.21.0
  • v1.21.1
  • v1.22.0
  • v1.23.0
  • v1.23.1
  • v1.23.2
  • v1.3.0
  • v1.3.1
  • v1.3.2
  • v1.4.0
  • v1.5.0
  • v1.5.1
  • v1.6.0
  • v1.6.1
  • v1.7.0
  • v1.7.1
  • v1.7.2
  • v1.7.3
  • v1.8.0
  • v1.8.1
  • v1.9.0
76 results
Show changes
Commits on Source (1)
Showing
with 25 additions and 18 deletions
...@@ -17,8 +17,9 @@ func (id JobID) String() string { ...@@ -17,8 +17,9 @@ func (id JobID) String() string {
return string(id) return string(id)
} }
type GetResult interface { type GetResultAndError interface {
GetResult() string GetResult() string
GetError() (string, int)
} }
// Priority is the priority of a job // Priority is the priority of a job
...@@ -206,6 +207,11 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) { ...@@ -206,6 +207,11 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) {
endTime := time.Now() endTime := time.Now()
elapsedTime := endTime.Sub(startTime) elapsedTime := endTime.Sub(startTime)
isSuccessful := runnerError == nil
if r.Status != ResultStatusSuccess {
isSuccessful = false
}
j.mu.Lock() j.mu.Lock()
defer j.mu.Unlock() defer j.mu.Unlock()
...@@ -235,8 +241,7 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) { ...@@ -235,8 +241,7 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) {
j.stats.TimeMetrics.AvgRunTime = j.stats.TimeMetrics.TotalRunTime / time.Duration(j.stats.RunCount) j.stats.TimeMetrics.AvgRunTime = j.stats.TimeMetrics.TotalRunTime / time.Duration(j.stats.RunCount)
} }
// Update SuccessCount or ErrorCount and codes if isSuccessful {
if runnerError == nil {
j.stats.SuccessCount++ j.stats.SuccessCount++
} else { } else {
j.stats.ErrorCount++ j.stats.ErrorCount++
...@@ -246,13 +251,23 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) { ...@@ -246,13 +251,23 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) {
StartTime: startTime, StartTime: startTime,
} }
if runnerError == nil { if isSuccessful {
newLog.IsSuccessful = true newLog.IsSuccessful = true
newLog.ExitCode = 0 newLog.ExitCode = 0
} else { } else {
switch v := any(r.Data).(type) {
case GetResultAndError:
newLog.ErrorMsg, newLog.ExitCode = v.GetError()
}
if newLog.ErrorMsg == "" {
newLog.ErrorMsg = runnerError.Error()
}
newLog.IsSuccessful = false newLog.IsSuccessful = false
newLog.ExitCode = 1 // Set to appropriate error code if applicable if newLog.ExitCode == 0 {
newLog.ErrorMsg = runnerError.Error() newLog.ExitCode = DefaultErrorExitCode
}
} }
newLog.StartTime = startTime newLog.StartTime = startTime
...@@ -260,11 +275,11 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) { ...@@ -260,11 +275,11 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) {
newLog.ProcessID = os.Getpid() // Assuming you want the PID of the current process newLog.ProcessID = os.Getpid() // Assuming you want the PID of the current process
newLog.EndTime = time.Now() newLog.EndTime = time.Now()
if runnerError != nil {
newLog.ErrorMsg = runnerError.Error()
}
newLog.Result = CheckAndCallGetResult(&r.Data) switch v := any(r.Data).(type) {
case GetResultAndError:
newLog.Result = v.GetResult()
}
j.logs = append(j.logs, newLog) j.logs = append(j.logs, newLog)
...@@ -272,14 +287,6 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) { ...@@ -272,14 +287,6 @@ func (j *Job[T]) Execute(ctx context.Context) (RunGenericResult, error) {
return genericResult, runnerError return genericResult, runnerError
} }
func CheckAndCallGetResult[T any](data T) string {
switch v := any(data).(type) {
case GetResult:
return v.GetResult()
}
return ""
}
// Cancel cancels the job, currently a no-op // Cancel cancels the job, currently a no-op
func (j *Job[T]) Cancel() error { func (j *Job[T]) Cancel() error {
return nil return nil
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755