jobqueue: Replace JobArgs() with Job()
JobArgs() function replaced with more general Job() function that returns all the parameters used to originally define a job during Enqueue(). This new function enables access to the type of a job in the queue, which wasn't available until now (except when Dequeueing).
This commit is contained in:
parent
75a96bd99d
commit
668fb003ef
6 changed files with 26 additions and 18 deletions
|
|
@ -121,19 +121,18 @@ func (s *Server) JobStatus(id uuid.UUID, result interface{}) (*JobStatus, []uuid
|
|||
}, deps, nil
|
||||
}
|
||||
|
||||
// JobArgs provides access to the arguments of a job.
|
||||
func (s *Server) JobArgs(id uuid.UUID, jobArgs interface{}) (json.RawMessage, error) {
|
||||
rawArgs, err := s.jobs.JobArgs(id)
|
||||
// Job provides access to all the parameters of a job.
|
||||
func (s *Server) Job(id uuid.UUID, job interface{}) (string, json.RawMessage, []uuid.UUID, error) {
|
||||
jobType, rawArgs, deps, err := s.jobs.Job(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return "", nil, nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(rawArgs, jobArgs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error unmarshaling arguments for job '%s': %v", id, err)
|
||||
if err := json.Unmarshal(rawArgs, job); err != nil {
|
||||
return "", nil, nil, fmt.Errorf("error unmarshaling arguments for job '%s': %v", id, err)
|
||||
}
|
||||
|
||||
return rawArgs, nil
|
||||
return jobType, rawArgs, deps, nil
|
||||
}
|
||||
|
||||
func (s *Server) Cancel(id uuid.UUID) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue