worker: Add JobArgs() method
Wraps jobqueue.JobArgs() method and unmarshals data into the provided concrete struct value. The struct should match the requested job type of the given ID.
This commit is contained in:
parent
6967333759
commit
1c5f6810be
1 changed files with 15 additions and 0 deletions
|
|
@ -121,6 +121,21 @@ 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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(rawArgs, jobArgs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error unmarshaling arguments for job '%s': %v", id, err)
|
||||
}
|
||||
|
||||
return rawArgs, nil
|
||||
}
|
||||
|
||||
func (s *Server) Cancel(id uuid.UUID) error {
|
||||
return s.jobs.CancelJob(id)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue