-
Notifications
You must be signed in to change notification settings - Fork 93
/
job.go
33 lines (28 loc) · 1.07 KB
/
job.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package river
import (
"github.com/riverqueue/river/rivertype"
)
// Job represents a single unit of work, holding both the arguments and
// information for a job with args of type T.
type Job[T JobArgs] struct {
*rivertype.JobRow
// Args are the arguments for the job.
Args T
}
// JobArgs is an interface that represents the arguments for a job of type T.
// These arguments are serialized into JSON and stored in the database.
//
// The struct is serialized using `encoding/json`. All exported fields are
// serialized, unless skipped with a struct field tag.
type JobArgs interface {
// Kind is a string that uniquely identifies the type of job. This must be
// provided on your job arguments struct.
Kind() string
}
// JobArgsWithInsertOpts is an extra interface that a job may implement on top
// of JobArgs to provide insertion-time options for all jobs of this type.
type JobArgsWithInsertOpts interface {
// InsertOpts returns options for all jobs of this job type, overriding any
// system defaults. These can also be overridden at insertion time.
InsertOpts() InsertOpts
}