// The internal API a task runner uses to communicate with a workflows-service. edition = "2023"; package workflows.v1; import "buf/validate/validate.proto"; import "google/protobuf/duration.proto"; import "tilebox/v1/id.proto"; import "workflows/v1/core.proto"; option features.field_presence = IMPLICIT; // NextTaskRequest is the request for requesting the next task to run and marking a task as computed. message NextTaskRequest { // The task that has been computed. If not set, the next task will ComputedTask computed_task = 1 [features.field_presence = EXPLICIT]; // The capabilities of the task runner, and therefore the potential tasks that can be run by that task runner. NextTaskToRun next_task_to_run = 2 [features.field_presence = EXPLICIT]; } // NextTaskToRun is a message specifying the capabilities of the task runner, and therefore the potential // tasks that can be run by that task runner. message NextTaskToRun { // The cluster that this task runner is running on. string cluster_slug = 1 [(buf.validate.field).string.min_len = 1]; // The concrete task addresses this runner can execute. Scoped capabilities include workflow_id; // omission advertises only an unscoped address. During the migration/introduction phase of scoped tasks, // runners advertise legacy unscoped aliases as separate entries. repeated TaskIdentifier identifiers = 2; } // ComputedTask is a message specifying a task that has been computed by the task runner. message ComputedTask { // The id of the task that has been computed. tilebox.v1.ID id = 1 [(buf.validate.field).required = true]; // A display name for the task that has been computed for visualization purposes. // If not set, the display message specified upon task submission will be kept. string display = 2; // A list of sub-tasks that the just computed task spawned. // Workflow scope must be explicitly set in the sub-task identifiers, omission means explicitly unscoped. // Cross-workflow child submissions are also allowed. TaskSubmissions sub_tasks = 5; // A list of progress updates that the computed task wants to report. repeated Progress progress_updates = 4; // A list of sub-tasks that the just computed task spawned. This field is deprecated and will be removed in the // future. Kept around for backwards compatibility. Workflow scope follows the same rules as sub_tasks. repeated SingleTaskSubmission legacy_sub_tasks = 3 [ deprecated = true, // we support more than that due to grouping and tree spawning, but we rather want to encourage users // to update their clients to use the new field which has way less serialization overhead. (buf.validate.field).repeated.max_items = 1000 ]; } // IdlingResponse is set in the response of a NextTaskRequest if no task was returned, indicating that the requesting // task runner should idle. message IdlingResponse { // The suggested duration the task runner should idle for before sending another request for a task. google.protobuf.Duration suggested_idling_duration = 1; } // NextTaskResponse is the response to the NextTask request. // If the NextTask request contained a request for a task, the response will either contain a next_task, or an idling // response, but not both. // If the NextTask request did not contain a request for a next task (indicating the the runner is about to shut down), // the response will be empty. message NextTaskResponse { option (buf.validate.message).oneof = { fields: [ "next_task", "idling" ] }; Task next_task = 1; IdlingResponse idling = 2; } // TaskFailedRequest is the request for marking a task as failed. message TaskFailedRequest { // The id of the task that has failed. tilebox.v1.ID task_id = 1 [(buf.validate.field).required = true]; // A display name for the task that has failed for visualization purposes. string display = 2; // Whether the failure was caused by the workflow itself, as opposed to a failure in the task runner // (e.g. a requested runner shutdown). If the task failure was not a workflow error, it won't be marked as failed, // but will instead be QUEUED again. Since the task didn't actually fail, this does not count as a retry. bool was_workflow_error = 3; // A list of progress updates that the failed task wants to report. Even if a task fails, it could // still have made some progress before failing, and we want to reflect that progress. // Since progress updates are idempotent, retrying the task and getting the same progress update again // is not an issue. repeated Progress progress_updates = 4; } // TaskStateResponse is the response to the TaskFailed request, // indicating the current state of the task marked as failed. message TaskStateResponse { TaskState state = 1; } // TaskLease is a message specifying the new lease expiration time of a task. message TaskLeaseRequest { tilebox.v1.ID task_id = 1 [(buf.validate.field).required = true]; google.protobuf.Duration requested_lease = 2; } // A service for task runners to communicate with the workflows service. service TaskService { // NextTask marks a task as computed and asks for the next task to run. // If no task marked as computed is sent, it is assumed that the task runner just started up or was idling so // the task server will send a task to run using a work-stealing algorithm. // If a task marked as computed is sent, the task server will send a next task to run using a depth first execution // algorithm, and only fall back to work-stealing if otherwise no tasks are available. // If the next_task_to_run field of the request is not set, a next task will never be returned, but a task // can still be marked as computed this way. rpc NextTask(NextTaskRequest) returns (NextTaskResponse); // TaskFailed tells the task server that we have failed to compute a task. // The task server will then mark the task as queued or failed, depending on the retry policy, // and possibly cancel the job. // If a task runner wants to continue executing tasks, it should afterwards fetch a new one using GetTaskToRun. rpc TaskFailed(TaskFailedRequest) returns (TaskStateResponse); // ExtendTaskLease is called by the task runner to extend the lease on a task. // On success, the response will contain the new lease expiration time. // If the task does not need to be extended, the response will be empty. rpc ExtendTaskLease(TaskLeaseRequest) returns (TaskLease); }