use of com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueQueryAndOwnTasksResponse in project appengine-java-standard by GoogleCloudPlatform.
the class LocalTaskQueue method queryAndOwnTasks.
@LatencyPercentiles(latency50th = 8)
public TaskQueueQueryAndOwnTasksResponse queryAndOwnTasks(Status status, TaskQueueQueryAndOwnTasksRequest request) {
String queueName = request.getQueueName().toStringUtf8();
validateQueueName(queueName);
// getQueueByName will throw UNKNOWN_QUEUE if the queue does not exist.
DevQueue queue = getQueueByName(queueName);
if (queue.getMode() != Mode.PULL) {
throw new ApiProxy.ApplicationException(ErrorCode.INVALID_QUEUE_MODE_VALUE);
}
DevPullQueue pullQueue = (DevPullQueue) queue;
List<TaskQueueAddRequest.Builder> results = pullQueue.queryAndOwnTasks(request.getLeaseSeconds(), request.getMaxTasks(), request.hasGroupByTag(), request.getTag().toByteArray());
TaskQueueQueryAndOwnTasksResponse.Builder response = TaskQueueQueryAndOwnTasksResponse.newBuilder();
for (TaskQueueAddRequest.Builder task : results) {
TaskQueueQueryAndOwnTasksResponse.Task.Builder responseTask = response.addTaskBuilder().setTaskName(task.getTaskName()).setBody(task.getBody()).setEtaUsec(task.getEtaUsec());
if (task.hasTag()) {
responseTask.setTag(task.getTag());
}
// TODO: To keep track of retry count, we can replace TaskQueueAddRequest with
// TaskQueueQueryTasksResponse to represent a task.
}
return response.build();
}
Aggregations