FINAL
A PushTask encapsulates a unit of work that an application places onto a Push Queue for asynchronous execution. The queue executes that work by sending the task back to the application in the form of an HTTP request to one of the application's handlers.
This class is immutable.
Constants
MAX_DELAY_SECONDS
A task may be scheduled up to 30 days into the future.
MAX_NAME_LENGTH
MAX_TASK_SIZE_BYTES
MAX_URL_LENGTH
NAME_PATTERN
Methods
__construct
__construct(string $url_path, array $query_data = array(), array $options = array())
Construct a PushTask.
Parameters
Name | Description |
---|---|
|
The path of the URL handler for this task relative to your application's root directory. |
|
The data carried by task, typically in the form of a set of key value pairs. This data will be encoded using http_build_query() and will be either:
|
|
Additional options for the task. Valid options are:
|
Throws
\google\appengine\api\taskqueue\InvalidArgumentException
if
- A supplied argument is not the correct type.
- Any of the specified options are invalid.
- The header 'content-type' is specified.
- Any supplied headers are not of the format 'key:value'.
getUrl
getUrl() : string
Return the task's URL. This will be the task's URL path, plus any query parameters if the task's method is GET, HEAD, or DELETE.
Returns
string
The task's URL path.
getQueryData
getQueryData() : array
Return the task's query data.
Returns
array
The task's query data.
getName
getName() : string
Return the task's name if it was explicitly named.
Returns
string
The task's name if it was explicity named, or empty string if it will be given a uniquely generated name in the queue.
getDelaySeconds
getDelaySeconds() : float
Return the task's execution delay, in seconds.
Returns
float
The task's execution delay in seconds.
getMethod
getMethod() : string
Return the task's HTTP method.
Returns
string
The task's HTTP method: 'DELETE', 'GET', 'HEAD', 'POST', or 'PUT'.
getHeaders
getHeaders() : array<mixed,string>
Return the task's headers.
Returns
array<mixed,string>
The headers that will be sent when the task is executed. This list is not exhaustive as the backend may add more headers at execution time. The array is numerically indexed and of the same format as that returned by the standard headers_list() function.
add
add( $queue_name = 'default') : string
Adds the task to a queue.
Parameters
Name | Description |
---|---|
|
Throws
\google\appengine\api\taskqueue\TaskAlreadyExistsException
if a task of the same name already exists in the queue.
\google\appengine\api\taskqueue\TaskQueueException
if there was a problem using the service.
Returns
string
The name of the task.