Fix client to return error when nil task is passed

This commit is contained in:
Ken Hibino
2022-03-10 15:59:58 -08:00
parent 888b5590fb
commit 562506c7ba
3 changed files with 62 additions and 0 deletions

View File

@@ -341,6 +341,9 @@ func (c *Client) Enqueue(task *Task, opts ...Option) (*TaskInfo, error) {
//
// The first argument context applies to the enqueue operation. To specify task timeout and deadline, use Timeout and Deadline option instead.
func (c *Client) EnqueueContext(ctx context.Context, task *Task, opts ...Option) (*TaskInfo, error) {
if task == nil {
return nil, fmt.Errorf("task cannot be nil")
}
if strings.TrimSpace(task.Type()) == "" {
return nil, fmt.Errorf("task typename cannot be empty")
}