feat(14-02): conga.Describe reports a registered job's kind, queue, attempts and timeout
- lets a plugin test assert what its Jobs() registers, such as the CSV match job's 240 s timeout, without reaching into conga internals - README API table, jobs docs page and an example
This commit is contained in:
@@ -107,6 +107,27 @@ func (w *riverWorker[T]) Timeout(*river.Job[T]) time.Duration {
|
||||
return w.job.cfg.timeout
|
||||
}
|
||||
|
||||
// JobInfo describes a job built by Job: its kind and the defaults its
|
||||
// options set (zero values mean the queue config defaults apply).
|
||||
type JobInfo struct {
|
||||
Kind string
|
||||
Queue string
|
||||
MaxAttempts int
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
// Describe returns the kind and option defaults of a job built by Job, so
|
||||
// a plugin's tests can assert what Jobs() registers (for example a job's
|
||||
// Timeout). ok is false for a pact.Job that was not built by Job.
|
||||
func Describe(j pact.Job) (info JobInfo, ok bool) {
|
||||
cj, ok := j.(congaJob)
|
||||
if !ok || cj == nil {
|
||||
return JobInfo{}, false
|
||||
}
|
||||
cfg := cj.config()
|
||||
return JobInfo{Kind: cj.kind(), Queue: cfg.queue, MaxAttempts: cfg.maxAttempts, Timeout: cfg.timeout}, true
|
||||
}
|
||||
|
||||
type jobIDKey struct{}
|
||||
|
||||
// JobID returns the summer_jobs id of the dispatched job running in ctx.
|
||||
|
||||
Reference in New Issue
Block a user