DeleteMulti deletes multiple tasks from a named queue. If a given task could not be deleted, an appengine.MultiError is returned. Each task is deleted independently; one may fail to delete while the others are successfully deleted.
(c context.Context, tasks []*Task, queueName string)
| 367 | // Each task is deleted independently; one may fail to delete while the others |
| 368 | // are successfully deleted. |
| 369 | func DeleteMulti(c context.Context, tasks []*Task, queueName string) error { |
| 370 | taskNames := make([][]byte, len(tasks)) |
| 371 | for i, t := range tasks { |
| 372 | taskNames[i] = []byte(t.Name) |
| 373 | } |
| 374 | if queueName == "" { |
| 375 | queueName = "default" |
| 376 | } |
| 377 | req := &pb.TaskQueueDeleteRequest{ |
| 378 | QueueName: []byte(queueName), |
| 379 | TaskName: taskNames, |
| 380 | } |
| 381 | res := &pb.TaskQueueDeleteResponse{} |
| 382 | if err := internal.Call(c, "taskqueue", "Delete", req, res); err != nil { |
| 383 | return err |
| 384 | } |
| 385 | if a, b := len(req.TaskName), len(res.Result); a != b { |
| 386 | return fmt.Errorf("taskqueue: internal error: requested deletion of %d tasks, got %d results", a, b) |
| 387 | } |
| 388 | me, any := make(appengine.MultiError, len(res.Result)), false |
| 389 | for i, ec := range res.Result { |
| 390 | if ec != pb.TaskQueueServiceError_OK { |
| 391 | me[i] = &internal.APIError{ |
| 392 | Service: "taskqueue", |
| 393 | Code: int32(ec), |
| 394 | } |
| 395 | any = true |
| 396 | } |
| 397 | } |
| 398 | if any { |
| 399 | return me |
| 400 | } |
| 401 | return nil |
| 402 | } |
| 403 | |
| 404 | func lease(c context.Context, maxTasks int, queueName string, leaseTime int, groupByTag bool, tag []byte) ([]*Task, error) { |
| 405 | if queueName == "" { |