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:
Jakub Zych
2026-10-03 20:56:49 +02:00
parent 0a7635b12a
commit cdd8d710fa
4 changed files with 34 additions and 1 deletions

View File

@@ -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.