1// Copyright 2023 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17package google.cloud.integrations.v1alpha; 18 19import "google/api/field_behavior.proto"; 20import "google/cloud/integrations/v1alpha/coordinate.proto"; 21import "google/cloud/integrations/v1alpha/event_parameter.proto"; 22import "google/cloud/integrations/v1alpha/json_validation.proto"; 23import "google/protobuf/timestamp.proto"; 24 25option csharp_namespace = "Google.Cloud.Integrations.V1Alpha"; 26option go_package = "cloud.google.com/go/integrations/apiv1alpha/integrationspb;integrationspb"; 27option java_multiple_files = true; 28option java_outer_classname = "TaskConfigProto"; 29option java_package = "com.google.cloud.integrations.v1alpha"; 30 31// The task configuration details. This is not the implementation of Task. 32// There might be multiple TaskConfigs for the same Task. 33message TaskConfig { 34 // Various policies for executing the next set of tasks. 35 enum NextTasksExecutionPolicy { 36 // Default. 37 NEXT_TASKS_EXECUTION_POLICY_UNSPECIFIED = 0; 38 39 // Execute all the tasks that satisfy their associated condition. 40 RUN_ALL_MATCH = 1; 41 42 // Execute the first task that satisfies the associated condition. 43 RUN_FIRST_MATCH = 2; 44 } 45 46 // Various policies to trigger the execution of this task. 47 enum TaskExecutionStrategy { 48 // Default. If the strategy is not set explicitly, it will default to 49 // `WHEN_ALL_SUCCEED`. 50 TASK_EXECUTION_STRATEGY_UNSPECIFIED = 0; 51 52 // Wait until all of its previous tasks finished execution, then verify at 53 // least one of the edge conditions is met, and execute if possible. This 54 // should be considered as WHEN_ALL_TASKS_SUCCEED. 55 WHEN_ALL_SUCCEED = 1; 56 57 // Start execution as long as any of its previous tasks finished execution 58 // and the corresponding edge condition is met (since we will execute if 59 // only that succeeding edge condition is met). 60 WHEN_ANY_SUCCEED = 2; 61 62 // Wait until all of its previous tasks finished execution, then verify 63 // the all edge conditions are met and execute if possible. 64 WHEN_ALL_TASKS_AND_CONDITIONS_SUCCEED = 3; 65 } 66 67 // Defines the type of the task for external customer 68 enum ExternalTaskType { 69 // Default value. External task type is not specified 70 EXTERNAL_TASK_TYPE_UNSPECIFIED = 0; 71 72 // Tasks belongs to the normal task flows 73 NORMAL_TASK = 1; 74 75 // Task belongs to the error catch task flows 76 ERROR_TASK = 2; 77 } 78 79 // Optional. The name for the task. 80 string task = 1 [(google.api.field_behavior) = OPTIONAL]; 81 82 // Required. The identifier of this task within its parent event config, 83 // specified by the client. This should be unique among all the tasks belong 84 // to the same event config. We use this field as the identifier to 85 // find next tasks (via field `next_tasks.task_id`). 86 string task_id = 2 [(google.api.field_behavior) = REQUIRED]; 87 88 // Optional. The customized parameters the user can pass to this task. 89 map<string, EventParameter> parameters = 3 90 [(google.api.field_behavior) = OPTIONAL]; 91 92 // Optional. Determines the number of times the 93 // task will be retried on failure and with what retry strategy. 94 // This is applicable for asynchronous calls to Eventbus alone (Post To 95 // Queue, Schedule etc.). 96 FailurePolicy failure_policy = 4 [(google.api.field_behavior) = OPTIONAL]; 97 98 // Optional. Determines the number of times the 99 // task will be retried on failure and with what retry strategy. 100 // This is applicable for synchronous calls to Eventbus alone (Post). 101 FailurePolicy synchronous_call_failure_policy = 5 102 [(google.api.field_behavior) = OPTIONAL]; 103 104 // Optional. The set of tasks that are next in line to be executed as per the 105 // execution graph defined for the parent event, specified by 106 // `event_config_id`. Each of these next tasks are executed 107 // only if the condition associated with them evaluates to true. 108 repeated NextTask next_tasks = 6 [(google.api.field_behavior) = OPTIONAL]; 109 110 // Optional. The policy dictating the execution of the next set of tasks for 111 // the current task. 112 NextTasksExecutionPolicy next_tasks_execution_policy = 7 113 [(google.api.field_behavior) = OPTIONAL]; 114 115 // Optional. The policy dictating the execution strategy of this task. 116 TaskExecutionStrategy task_execution_strategy = 8 117 [(google.api.field_behavior) = OPTIONAL]; 118 119 // Optional. User-provided label that is attached to this TaskConfig in the 120 // UI. 121 string display_name = 9 [(google.api.field_behavior) = OPTIONAL]; 122 123 // Optional. Determines what action to take upon successful task completion. 124 SuccessPolicy success_policy = 10 [(google.api.field_behavior) = OPTIONAL]; 125 126 // Optional. If set, overrides the option configured in the Task 127 // implementation class. 128 JsonValidationOption json_validation_option = 11 129 [(google.api.field_behavior) = OPTIONAL]; 130 131 // Optional. User-provided description intended to give additional business 132 // context about the task. 133 string description = 12 [(google.api.field_behavior) = OPTIONAL]; 134 135 // Optional. Used to define task-template name if task is of type 136 // task-template 137 string task_template = 13 [(google.api.field_behavior) = OPTIONAL]; 138 139 // Optional. Optional 140 // Error catcher id of the error catch flow which will be executed when 141 // execution error happens in the task 142 string error_catcher_id = 17 [(google.api.field_behavior) = OPTIONAL]; 143 144 // Optional. External task type of the task 145 ExternalTaskType external_task_type = 15 146 [(google.api.field_behavior) = OPTIONAL]; 147 148 // Optional. Informs the front-end application where to draw this error 149 // catcher config on the UI. 150 Coordinate position = 16 [(google.api.field_behavior) = OPTIONAL]; 151} 152 153// Policy that dictates the behavior for the task after it completes 154// successfully. 155message SuccessPolicy { 156 // The state of execution. 157 enum FinalState { 158 // UNSPECIFIED. 159 FINAL_STATE_UNSPECIFIED = 0; 160 161 // The default behavior, where successful tasks will be marked as SUCCEEDED. 162 SUCCEEDED = 1; 163 164 // Sets the state to SUSPENDED after executing. This is required for 165 // SuspensionTask; event execution will continue once the user calls 166 // ResolveSuspensions with the event_execution_info_id and the task number. 167 SUSPENDED = 2; 168 } 169 170 // State to which the execution snapshot status will be set if the task 171 // succeeds. 172 FinalState final_state = 1; 173} 174 175// Policy that defines the task retry logic and failure type. If no 176// FailurePolicy is defined for a task, all its dependent tasks will not be 177// executed (i.e, a `retry_strategy` of NONE will be applied). 178message FailurePolicy { 179 // The behavior when the taks failed. 180 enum RetryStrategy { 181 // UNSPECIFIED. 182 RETRY_STRATEGY_UNSPECIFIED = 0; 183 184 // Ignores the failure of this task. The rest of the integration will be 185 // executed Assuming this task succeeded. 186 IGNORE = 1; 187 188 // Causes a permanent failure of the task. However, if the last task(s) 189 // of event was successfully completed despite the failure of this task, 190 // it has no impact on the integration. 191 NONE = 2; 192 193 // Causes a permanent failure of the event. It is different from NONE 194 // because this will mark the event as FAILED by shutting down the 195 // event execution. 196 FATAL = 3; 197 198 // The task will be retried from the failed task onwards after a fixed 199 // delay. A max-retry count is required to be specified with this 200 // strategy. A jitter is added to each exponential interval so that 201 // concurrently failing tasks of the same type do not end up retrying 202 // after the exact same exponential interval. max_retries and 203 // interval_in_seconds must be specified. 204 FIXED_INTERVAL = 4; 205 206 // The task will be retried from the failed task onwards after a fixed 207 // delay that linearly increases with each retry attempt. A jitter is 208 // added to each exponential interval so that concurrently failing tasks 209 // of the same type do not end up retrying after the exact same 210 // exponential interval. A max-retry count is required to be specified 211 // with this strategy. max_retries and interval_in_seconds must be 212 // specified. 213 LINEAR_BACKOFF = 5; 214 215 // The task will be retried after an exponentially increasing period of 216 // time with each failure. A jitter is added to each exponential interval 217 // so that concurrently failing tasks of the same type do not end up 218 // retrying after the exact same exponential interval. A max-retry count 219 // is required to be specified with this strategy. `max_retries` and 220 // `interval_in_seconds` must be specified. 221 EXPONENTIAL_BACKOFF = 6; 222 223 // The entire integration will be restarted with the initial parameters that 224 // were set when the event was fired. A max-retry count is required to be 225 // specified with this strategy. `max_retries` and `interval_in_seconds` 226 // must be specified. 227 RESTART_INTEGRATION_WITH_BACKOFF = 7; 228 } 229 230 // Defines what happens to the task upon failure. 231 RetryStrategy retry_strategy = 1; 232 233 // Required if retry_strategy is FIXED_INTERVAL or 234 // LINEAR/EXPONENTIAL_BACKOFF/RESTART_INTEGRATION_WITH_BACKOFF. Defines the 235 // number of times the task will be retried if failed. 236 int32 max_retries = 2; 237 238 // Required if retry_strategy is FIXED_INTERVAL or 239 // LINEAR/EXPONENTIAL_BACKOFF/RESTART_INTEGRATION_WITH_BACKOFF. Defines the 240 // initial interval in seconds for backoff. 241 google.protobuf.Timestamp interval_time = 3; 242} 243 244// The task that is next in line to be executed, if the 245// condition specified evaluated to true. 246message NextTask { 247 // ID of the next task. 248 string task_config_id = 1; 249 250 // Task number of the next task. 251 string task_id = 2; 252 253 // Standard filter expression for this task to become an eligible next task. 254 string condition = 3; 255 256 // User-provided label that is attached to this edge in the UI. 257 string display_name = 4; 258 259 // User-provided description intended to give additional business context 260 // about the task. 261 string description = 5; 262} 263