task_config.proto 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // Copyright 2021 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. syntax = "proto3";
  15. package google.cloud.integrations.v1alpha;
  16. import "google/api/field_behavior.proto";
  17. import "google/cloud/integrations/v1alpha/event_parameter.proto";
  18. import "google/cloud/integrations/v1alpha/json_validation.proto";
  19. import "google/protobuf/timestamp.proto";
  20. option go_package = "google.golang.org/genproto/googleapis/cloud/integrations/v1alpha;integrations";
  21. option java_multiple_files = true;
  22. option java_outer_classname = "TaskConfigProto";
  23. option java_package = "com.google.cloud.integrations.v1alpha";
  24. // The task configuration details. This is not the implementation of Task.
  25. // There might be multiple TaskConfigs for the same Task.
  26. // (-- Next available id: 12 --)
  27. message TaskConfig {
  28. // Various policies for executing the next set of tasks.
  29. enum NextTasksExecutionPolicy {
  30. // Default.
  31. NEXT_TASKS_EXECUTION_POLICY_UNSPECIFIED = 0;
  32. // Execute all the tasks that satisfy their associated condition.
  33. RUN_ALL_MATCH = 1;
  34. // Execute the first task that satisfies the associated condition.
  35. RUN_FIRST_MATCH = 2;
  36. }
  37. // Various policies to trigger the execution of this task.
  38. enum TaskExecutionStrategy {
  39. // Default. If the strategy is not set explicitly, it will default to
  40. // `WHEN_ALL_SUCCEED`.
  41. TASK_EXECUTION_STRATEGY_UNSPECIFIED = 0;
  42. // Wait until all of its previous tasks finished execution, then verify at
  43. // least one of the edge conditions is met, and execute if possible. This
  44. // should be considered as WHEN_ALL_TASKS_SUCCEED.
  45. WHEN_ALL_SUCCEED = 1;
  46. // Start execution as long as any of its previous tasks finished execution
  47. // and the corresponding edge condition is met (since we will execute if
  48. // only that succeeding edge condition is met).
  49. WHEN_ANY_SUCCEED = 2;
  50. // Wait until all of its previous tasks finished execution, then verify
  51. // the all edge conditions are met and execute if possible.
  52. WHEN_ALL_TASKS_AND_CONDITIONS_SUCCEED = 3;
  53. }
  54. // Optional. The name for the task.
  55. string task = 1 [(google.api.field_behavior) = OPTIONAL];
  56. // Required. The identifier of this task within its parent event config,
  57. // specified by the client. This should be unique among all the tasks belong
  58. // to the same event config. We use this field as the identifier to
  59. // find next tasks (via field `next_tasks.task_id`).
  60. string task_id = 2 [(google.api.field_behavior) = REQUIRED];
  61. // Optional. The customized parameters the user can pass to this task.
  62. map<string, EventParameter> parameters = 3 [(google.api.field_behavior) = OPTIONAL];
  63. // Optional. Determines the number of times the
  64. // task will be retried on failure and with what retry strategy.
  65. // This is applicable for asynchronous calls to Eventbus alone (Post To
  66. // Queue, Schedule etc.).
  67. FailurePolicy failure_policy = 4 [(google.api.field_behavior) = OPTIONAL];
  68. // Optional. Determines the number of times the
  69. // task will be retried on failure and with what retry strategy.
  70. // This is applicable for synchronous calls to Eventbus alone (Post).
  71. FailurePolicy synchronous_call_failure_policy = 5 [(google.api.field_behavior) = OPTIONAL];
  72. // Optional. The set of tasks that are next in line to be executed as per the
  73. // execution graph defined for the parent event, specified by
  74. // `event_config_id`. Each of these next tasks are executed
  75. // only if the condition associated with them evaluates to true.
  76. repeated NextTask next_tasks = 6 [(google.api.field_behavior) = OPTIONAL];
  77. // Optional. The policy dictating the execution of the next set of tasks for the current
  78. // task.
  79. NextTasksExecutionPolicy next_tasks_execution_policy = 7 [(google.api.field_behavior) = OPTIONAL];
  80. // Optional. The policy dictating the execution strategy of this task.
  81. TaskExecutionStrategy task_execution_strategy = 8 [(google.api.field_behavior) = OPTIONAL];
  82. // Optional. User-provided label that is attached to this TaskConfig in the UI.
  83. string display_name = 9 [(google.api.field_behavior) = OPTIONAL];
  84. // Optional. Determines what action to take upon successful task completion.
  85. SuccessPolicy success_policy = 10 [(google.api.field_behavior) = OPTIONAL];
  86. // Optional. If set, overrides the option configured in the Task implementation class.
  87. JsonValidationOption json_validation_option = 11 [(google.api.field_behavior) = OPTIONAL];
  88. }
  89. // Policy that dictates the behavior for the task after it completes
  90. // successfully.
  91. message SuccessPolicy {
  92. // The state of execution.
  93. enum FinalState {
  94. // UNSPECIFIED.
  95. FINAL_STATE_UNSPECIFIED = 0;
  96. // The default behavior, where successful tasks will be marked as SUCCEEDED.
  97. SUCCEEDED = 1;
  98. // Sets the state to SUSPENDED after executing. This is required for
  99. // SuspensionTask; event execution will continue once the user calls
  100. // ResolveSuspensions with the event_execution_info_id and the task number.
  101. SUSPENDED = 2;
  102. }
  103. // State to which the execution snapshot status will be set if the task
  104. // succeeds.
  105. FinalState final_state = 1;
  106. }
  107. // Policy that defines the task retry logic and failure type. If no
  108. // FailurePolicy is defined for a task, all its dependent tasks will not be
  109. // executed (i.e, a `retry_strategy` of NONE will be applied).
  110. message FailurePolicy {
  111. // The behavior when the taks failed.
  112. enum RetryStrategy {
  113. // UNSPECIFIED.
  114. RETRY_STRATEGY_UNSPECIFIED = 0;
  115. // Ignores the failure of this task. The rest of the integration will be
  116. // executed Assuming this task succeeded.
  117. IGNORE = 1;
  118. // Causes a permanent failure of the task. However, if the last task(s)
  119. // of event was successfully completed despite the failure of this task,
  120. // it has no impact on the integration.
  121. NONE = 2;
  122. // Causes a permanent failure of the event. It is different from NONE
  123. // because this will mark the event as FAILED by shutting down the
  124. // event execution.
  125. FATAL = 3;
  126. // The task will be retried from the failed task onwards after a fixed
  127. // delay. A max-retry count is required to be specified with this
  128. // strategy. A jitter is added to each exponential interval so that
  129. // concurrently failing tasks of the same type do not end up retrying
  130. // after the exact same exponential interval. max_retries and
  131. // interval_in_seconds must be specified.
  132. FIXED_INTERVAL = 4;
  133. // The task will be retried from the failed task onwards after a fixed
  134. // delay that linearly increases with each retry attempt. A jitter is
  135. // added to each exponential interval so that concurrently failing tasks
  136. // of the same type do not end up retrying after the exact same
  137. // exponential interval. A max-retry count is required to be specified
  138. // with this strategy. max_retries and interval_in_seconds must be
  139. // specified.
  140. LINEAR_BACKOFF = 5;
  141. // The task will be retried after an exponentially increasing period of
  142. // time with each failure. A jitter is added to each exponential interval
  143. // so that concurrently failing tasks of the same type do not end up
  144. // retrying after the exact same exponential interval. A max-retry count
  145. // is required to be specified with this strategy. `max_retries` and
  146. // `interval_in_seconds` must be specified.
  147. EXPONENTIAL_BACKOFF = 6;
  148. // The entire integration will be restarted with the initial parameters that
  149. // were set when the event was fired. A max-retry count is required to be
  150. // specified with this strategy. `max_retries` and `interval_in_seconds`
  151. // must be specified.
  152. RESTART_INTEGRATION_WITH_BACKOFF = 7;
  153. }
  154. // Defines what happens to the task upon failure.
  155. RetryStrategy retry_strategy = 1;
  156. // Required if retry_strategy is FIXED_INTERVAL or
  157. // LINEAR/EXPONENTIAL_BACKOFF/RESTART_INTEGRATION_WITH_BACKOFF. Defines the
  158. // number of times the task will be retried if failed.
  159. int32 max_retries = 2;
  160. // Required if retry_strategy is FIXED_INTERVAL or
  161. // LINEAR/EXPONENTIAL_BACKOFF/RESTART_INTEGRATION_WITH_BACKOFF. Defines the
  162. // initial interval in seconds for backoff.
  163. google.protobuf.Timestamp interval_time = 3;
  164. }
  165. // The task that is next in line to be executed, if the
  166. // condition specified evaluated to true.
  167. message NextTask {
  168. // ID of the next task.
  169. string task_config_id = 1;
  170. // Task number of the next task.
  171. string task_id = 2;
  172. // Standard filter expression for this task to become an eligible next task.
  173. string condition = 3;
  174. // User-provided label that is attached to this edge in the UI.
  175. string display_name = 4;
  176. }