runTask method

  1. @override
Future<Task> runTask(
  1. RunTaskRequest request
)
override

Forces a task to run now.

When this method is called, Cloud Tasks will dispatch the task, even if the task is already running, the queue has reached its RateLimits or is PAUSED.

This command is meant to be used for manual debugging. For example, RunTask can be used to retry a failed task after a fix has been made or to manually force a task to be dispatched now.

The dispatched task is returned. That is, the task that is returned contains the status after the task is dispatched but before the task is received by its target.

If Cloud Tasks receives a successful response from the task's target, then the task will be deleted; otherwise the task's schedule_time will be reset to the time that RunTask was called plus the retry delay specified in the queue's RetryConfig.

RunTask returns NOT_FOUND when it is called on a task that has already succeeded or permanently failed.

Throws a http.ClientException if there were problems communicating with the API service. Throws a ServiceException if the API method failed for any reason.

Implementation

@override
Future<Task> runTask(RunTaskRequest request) async {
  if (isClosed) throw StateError('Service is closed');

  if (_runTask case final runTask?) {
    return runTask(request);
  }
  throw UnsupportedError('runTask');
}