Documentation
¶
Overview ¶
Package cloud_tasks creates and reads Cloud Tasks tasks over the REST API.
Only the HTTP request is modelled. The API also dispatches to App Engine; nothing here uses that, and a type for something no caller sends is a type nobody checks.
The queue itself is not managed here. A queue is infrastructure -- its rate, its concurrency and its retry policy are the things an operator sets and a deployment declares -- so it belongs in whatever describes the rest of the project's resources, not in the code that fills it. What this does is put work into a queue that already exists.
A task's identity is its full resource name, projects/P/locations/L/queues/Q/tasks/T. Create takes the parent and the id separately because that is how the API takes them; everything else takes the name Create returned.
Index ¶
- Constants
- Variables
- func Parent(project string, location string, queue string) (string, error)
- type Client
- func (client *Client) CreateTask(ctx context.Context, parent string, taskId string, newTask *task.Task, ...) (*task.Task, error)
- func (client *Client) DeleteTask(ctx context.Context, name string, options ...fetch_config.Option) error
- func (client *Client) GetTask(ctx context.Context, name string, options ...fetch_config.Option) (*task.Task, error)
- func (client *Client) ListTasks(ctx context.Context, parent string, options ...fetch_config.Option) ([]*task.Task, error)
Constants ¶
const Domain = "cloudtasks.googleapis.com"
const Scope = "https://www.googleapis.com/auth/cloud-tasks"
Scope is the OAuth scope a token must carry to manage tasks. The broader cloud-platform scope also works and is what a Cloud Run runtime identity usually has.
Variables ¶
var ErrTaskExists = errors.New("a task with that name already exists")
ErrTaskExists is a task whose name has been used recently.
It is worth telling apart from any other failure, because it is the answer a caller naming its tasks is asking for: the work is already queued, or has just been done, and asking again is not something to report as broken. Cloud Tasks keeps a name reserved for about an hour after the task it belonged to ran or was deleted, so this is also what a caller sees when it asks for the same work twice in quick succession.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(options ...cloud_tasks_config.Option) *Client
func (*Client) CreateTask ¶
func (client *Client) CreateTask( ctx context.Context, parent string, taskId string, newTask *task.Task, options ...fetch_config.Option, ) (*task.Task, error)
CreateTask puts a task into the queue and returns it as the server recorded it.
taskId is optional. Given one, the queue will refuse a second task of the same name, which is how duplicate work is kept out; see task.Task.Name for what that costs. Left empty, the server names the task and every call queues new work.
A refused duplicate comes back as ErrTaskExists rather than as a failure, because to a caller naming its tasks that is an answer rather than a fault.
func (*Client) DeleteTask ¶
func (client *Client) DeleteTask( ctx context.Context, name string, options ...fetch_config.Option, ) error
DeleteTask removes a task from the queue, whether or not it has run.
It does not free the name: a deleted task's name stays reserved for about an hour, which is what keeps a delete-and-recreate from being a way around the duplicate check.
func (*Client) GetTask ¶
func (client *Client) GetTask( ctx context.Context, name string, options ...fetch_config.Option, ) (*task.Task, error)
GetTask reads one task by its full resource name.
func (*Client) ListTasks ¶
func (client *Client) ListTasks( ctx context.Context, parent string, options ...fetch_config.Option, ) ([]*task.Task, error)
ListTasks reads every task in a queue, following the pages until there are none left.
It is for looking at a queue rather than for working through one: a task is dispatched by the queue, not by a reader, and a queue long enough for the paging to matter is one nothing should be listing. The basic view comes back, so the bodies are not included.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cloud_tasks_config holds the settings of a Cloud Tasks client.
|
Package cloud_tasks_config holds the settings of a Cloud Tasks client. |
|
types
|
|