github.com/matrixorigin/matrixone@v1.2.0/proto/task.proto (about) 1 /* 2 * Copyright 2021 Matrix Origin 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 syntax = "proto3"; 18 package task; 19 option go_package = "github.com/matrixorigin/matrixone/pkg/pb/task"; 20 21 import "github.com/gogo/protobuf/gogoproto/gogo.proto"; 22 import "google/protobuf/timestamp.proto"; 23 import "metadata.proto"; 24 25 option (gogoproto.goproto_enum_prefix_all) = true; 26 27 // TaskStatus task status 28 enum TaskStatus { 29 // Create is the state of waiting to be scheduled. 30 Created = 0; 31 // Running is running state. Task is assigned to a CN node and is running 32 Running = 1; 33 // Completed the task has been completed. 34 Completed = 2; 35 // Paused is the state that the task has been paused by user. 36 Paused = 3; 37 // Error is the state that the task encounters some kind of error. 38 Error = 4; 39 // Canceled is the state that the task is canceled by user. 40 Canceled = 5; 41 // ResumeRequested is the state that resume request has been proposed to 42 // the task and has not been resume. 43 ResumeRequested = 6; 44 // PauseRequested is the state that pause request has been proposed to 45 // the task and has not been paused. 46 PauseRequested = 7; 47 // CancelRequested is the state that cancel request has been proposed to 48 // the task and has not been canceled. 49 CancelRequested = 8; 50 } 51 52 // TaskCode task code 53 enum TaskCode { 54 // TestOnly reserved for testing. 55 TestOnly = 0; 56 // SystemInit system init task 57 SystemInit = 1; 58 // MetricLogMerge handle metric/log exported data merge task 59 MetricLogMerge = 2; 60 // MetricStorageUsage handle metric server_storage_usage collection 61 MetricStorageUsage = 3; 62 // ConnectorKafkaSink is for the streaming connector task. 63 ConnectorKafkaSink = 4; 64 // MergeObject is for the merge object task. 65 MergeObject = 5; 66 } 67 68 // TaskMetadata is a task metadata abstraction that can be scheduled for execution at any CN node. 69 message TaskMetadata { 70 // ID task id, global unique 71 string ID = 1; 72 // Executor used to select a particular task executor to run a task 73 TaskCode Executor = 2; 74 // Context context needed to run the task 75 bytes Context = 3; 76 // Options options for execute task 77 TaskOptions Options = 4 [(gogoproto.nullable) = false]; 78 } 79 80 // TaskOptions task options 81 message TaskOptions { 82 // MaxRetryTimes 0 means disable retry 83 uint32 MaxRetryTimes = 1; 84 // RetryInterval retry interval 85 int64 RetryInterval = 2; 86 // DelayDuration delay duration. Controls how long a task is delayed before it is scheduled for 87 // execution. 88 int64 DelayDuration = 3; 89 // Concurrency is the max number of a task running at the same time. 0 means no limits. 90 uint32 Concurrency = 4; 91 // Labels indicates that the task should run on the CNs with the Labels. 92 map<string, string> Labels = 5; 93 // Resource required by the task 94 Resource Resource = 6; 95 } 96 97 // Resource task resource 98 message Resource { 99 // CPU cpu resource 100 uint64 CPU = 1; 101 // Memory memory resource 102 uint64 Memory = 2; 103 } 104 105 // ResultCode result code 106 enum ResultCode { 107 // Success success 108 Success = 0; 109 // Failed failed 110 Failed = 1; 111 } 112 113 // ExecuteResult task execute result 114 message ExecuteResult { 115 // Code result code 116 ResultCode Code = 1; 117 // Error error message 118 string Error = 2; 119 } 120 121 // Task task execute info. 122 message AsyncTask { 123 uint64 ID = 1; 124 // TaskMetadata task metadata 125 TaskMetadata Metadata = 2 [(gogoproto.nullable) = false]; 126 // ParentTaskID used to record the parent task of the current task 127 string ParentTaskID = 3; 128 // TaskStatus task status 129 TaskStatus Status = 4; 130 // TaskRunner is the UUID of the CN node which the task run is assigned to 131 string TaskRunner = 5; 132 // Epoch indicates how many times the current task is scheduled, the first time it is scheduled 133 // is 1. Each time it is scheduled, Epoch++. 134 uint32 Epoch = 6; 135 // LastHeartbeat time of the last heartbeat reported by TaskRunner. Unix timestamp in ms 136 int64 LastHeartbeat = 7; 137 // CreateAt time of the task created. Unix timestamp in ms 138 int64 CreateAt = 8; 139 // CompletedAt time of the task completed. Unix timestamp in ms 140 int64 CompletedAt = 9; 141 // ExecuteResult execute result 142 ExecuteResult ExecuteResult = 10; 143 } 144 145 // CronTask task execute info. 146 message CronTask { 147 uint64 ID = 1; 148 // TaskMetadata task metadata 149 TaskMetadata Metadata = 2 [(gogoproto.nullable) = false]; 150 // CronExpr cron expr 151 string CronExpr = 3; 152 // NextTime the next time it should be scheduled for execution. Unix timestamp in ms 153 int64 NextTime = 4; 154 // TriggerTimes the number of times it was triggered 155 uint64 TriggerTimes = 5; 156 // CreateAt time of the cron task created. Unix timestamp in ms 157 int64 CreateAt = 6; 158 // CreateAt time of the cron task created. Unix timestamp in ms 159 int64 UpdateAt = 7; 160 } 161 162 enum TaskType { 163 Unknown = 0 [(gogoproto.enumvalue_customname) = "TypeUnknown"]; 164 KafkaSinkConnector = 1 [(gogoproto.enumvalue_customname) = "TypeKafkaSinkConnector"]; 165 } 166 167 message ConnectorDetails { 168 string TableName = 1; 169 map<string, string> Options = 2; 170 } 171 172 message Details { 173 string Description = 1; 174 uint32 AccountID = 2; 175 string Account = 3; 176 string Username = 4; 177 string Error = 5; 178 oneof Details { 179 ConnectorDetails Connector = 10; 180 } 181 } 182 183 message DaemonTask { 184 uint64 ID = 1; 185 TaskMetadata Metadata = 2 [(gogoproto.nullable) = false]; 186 uint32 AccountID = 3; 187 string Account = 4; 188 TaskType TaskType = 5; 189 string TaskRunner = 6; 190 TaskStatus TaskStatus = 7; 191 google.protobuf.Timestamp LastHeartbeat = 8 192 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; 193 Details Details = 9; 194 google.protobuf.Timestamp CreateAt = 10 195 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; 196 google.protobuf.Timestamp UpdateAt = 11 197 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; 198 google.protobuf.Timestamp EndAt = 12 199 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; 200 google.protobuf.Timestamp LastRun = 13 201 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; 202 }