Update NewTask function to take Option as varargs

This commit is contained in:
Ken Hibino
2021-09-10 05:56:17 -07:00
parent 23c522dc9f
commit 83cae4bb24
4 changed files with 31 additions and 34 deletions

View File

@@ -23,16 +23,21 @@ type Task struct {
// payload holds data needed to perform the task.
payload []byte
// opts holds options for the task.
opts []Option
}
func (t *Task) Type() string { return t.typename }
func (t *Task) Payload() []byte { return t.payload }
// NewTask returns a new Task given a type name and payload data.
func NewTask(typename string, payload []byte) *Task {
// Options can be passed to configure task processing behavior.
func NewTask(typename string, payload []byte, opts ...Option) *Task {
return &Task{
typename: typename,
payload: payload,
opts: opts,
}
}