AFAIRE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.7 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### jw ####### Copyright (c) 2021 losyme ####################################################### MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package jw
import "time"
type Result struct {
Status Status `json:"status"`
NextStep string `json:"next_step"`
Value string `json:"value"`
Duration time.Duration `json:"duration"`
Error string `json:"error"`
Host string `json:"host"`
Worker string `json:"worker"`
}
func (job *Job) Failed() *Result {
job.Result = &Result{
Status: StatusFailed,
}
return job.Result
}
func (job *Job) Pending() *Result {
job.Result = &Result{
Status: StatusPending,
}
return job.Result
}
func (job *Job) Succeeded() *Result {
job.Result = &Result{
Status: StatusSucceeded,
}
return job.Result
}
func (r *Result) SetNextStep(nextStep string) *Result {
r.NextStep = nextStep
return r
}
func (r *Result) SetValue(value string) *Result {
r.Value = value
return r
}
func (r *Result) SetDuration(duration time.Duration) *Result {
r.Duration = duration
return r
}
func (r *Result) SetError(err string) *Result {
r.Error = err
return r
}
func (r *Result) Fields() []interface{} {
return []interface{}{
"status", r.Status,
"next_step", r.NextStep,
"value", r.Value,
"duration", r.Duration.String(),
"error", r.Error,
}
}
/*
######################################################################################################## @(°_°)@ #######
*/