diff --git a/client.go b/client.go index 96ef557..cb12b1f 100644 --- a/client.go +++ b/client.go @@ -68,6 +68,9 @@ const ( // // Process returns nil if the task is registered successfully, // otherwise returns non-nil error. +// +// opts specifies the behavior of task processing. If there are conflicting +// Option the last one overrides the ones before. func (c *Client) Process(task *Task, processAt time.Time, opts ...Option) error { opt := composeOptions(opts...) msg := &rdb.TaskMessage{ diff --git a/client_test.go b/client_test.go index 0d838f7..b71ece6 100644 --- a/client_test.go +++ b/client_test.go @@ -89,6 +89,24 @@ func TestClient(t *testing.T) { }, wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil }, + { + desc: "Conflicting options", + task: task, + processAt: time.Now(), + opts: []Option{ + MaxRetry(2), + MaxRetry(10), + }, + wantEnqueued: []*rdb.TaskMessage{ + &rdb.TaskMessage{ + Type: task.Type, + Payload: task.Payload, + Retry: 10, // Last option takes precedence + Queue: "default", + }, + }, + wantScheduled: nil, // db is flushed in setup so zset does not exist hence nil + }, } for _, tc := range tests {