MCPcopy Create free account
hub / github.com/golang/appengine / Add

Function Add

taskqueue/taskqueue.go:285–304  ·  view source on GitHub ↗

Add adds the task to a named queue. An empty queue name means that the default queue will be used. Add returns an equivalent Task with defaults filled in, including setting the task's Name field to the chosen name if the original was empty.

(c context.Context, task *Task, queueName string)

Source from the content-addressed store, hash-verified

283// Add returns an equivalent Task with defaults filled in, including setting
284// the task's Name field to the chosen name if the original was empty.
285func Add(c context.Context, task *Task, queueName string) (*Task, error) {
286 req, err := newAddReq(c, task, queueName)
287 if err != nil {
288 return nil, err
289 }
290 res := &pb.TaskQueueAddResponse{}
291 if err := internal.Call(c, "taskqueue", "Add", req, res); err != nil {
292 apiErr, ok := err.(*internal.APIError)
293 if ok && alreadyAddedErrors[pb.TaskQueueServiceError_ErrorCode(apiErr.Code)] {
294 return nil, ErrTaskAlreadyAdded
295 }
296 return nil, err
297 }
298 resultTask := *task
299 resultTask.Method = task.method()
300 if task.Name == "" {
301 resultTask.Name = string(res.ChosenTaskName)
302 }
303 return &resultTask, nil
304}
305
306// AddMulti adds multiple tasks to a named queue.
307// An empty queue name means that the default queue will be used.

Callers 2

TestAddErrorsFunction · 0.70
TestAddWithEmptyPathFunction · 0.70

Calls 3

CallFunction · 0.92
newAddReqFunction · 0.70
methodMethod · 0.45

Tested by 2

TestAddErrorsFunction · 0.56
TestAddWithEmptyPathFunction · 0.56