github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/proto/master.proto (about)

     1  syntax = "proto3";
     2  
     3  package enginepb;
     4  
     5  import "google/api/annotations.proto";
     6  import "google/api/field_behavior.proto";
     7  import "google/protobuf/empty.proto";
     8  
     9  import "engine/proto/resources.proto";
    10  
    11  option go_package = "github.com/pingcap/tiflow/engine/enginepb";
    12  
    13  service Discovery {
    14      rpc RegisterExecutor(RegisterExecutorRequest) returns(Executor) {
    15          option (google.api.http) = {
    16              post: "/api/v1/executors/register"
    17              body: "executor"
    18          };
    19      }
    20  
    21      // ListExecutors lists all executors.
    22      // Executors will use this API to discover other executors.
    23      // Currently, we assume that there aren't too many executors.
    24      // If the number of executors becomes very large in the future,
    25      // we can consider a mechanism to watch the changes of the executors.
    26      rpc ListExecutors(ListExecutorsRequest) returns(ListExecutorsResponse) {
    27          option (google.api.http) = {
    28              get: "/api/v1/executors"
    29          };
    30      }
    31  
    32      rpc ListMasters(ListMastersRequest) returns(ListMastersResponse) {
    33          option (google.api.http) = {
    34              get: "/api/v1/masters"
    35          };
    36      }
    37  
    38      rpc Heartbeat(HeartbeatRequest) returns(HeartbeatResponse) {}
    39  
    40  
    41      // QueryMetaStore queries metastore manager and returns the information of a matching metastore.
    42      rpc QueryMetaStore(QueryMetaStoreRequest) returns(QueryMetaStoreResponse) {}
    43      
    44      // QueryStorageConfig queries and returns external storage config.
    45      rpc QueryStorageConfig(QueryStorageConfigRequest) returns(QueryStorageConfigResponse) {}
    46  
    47      rpc GetLeader(GetLeaderRequest) returns(GetLeaderResponse) {
    48          option (google.api.http) = {
    49              get: "/api/v1/leader"
    50          };
    51      }
    52  
    53      rpc ResignLeader(ResignLeaderRequest) returns(google.protobuf.Empty) {
    54          option (google.api.http) = {
    55              post: "/api/v1/leader/resign"
    56          };
    57      }
    58  }
    59  
    60  service TaskScheduler {
    61      rpc ScheduleTask(ScheduleTaskRequest) returns(ScheduleTaskResponse) {}
    62  }
    63  
    64  // Refer to: https://cloud.google.com/apis/design/standard_methods 
    65  service JobManager {
    66      rpc CreateJob(CreateJobRequest) returns (Job){
    67          option (google.api.http) = {
    68              post: "/api/v1/jobs"
    69              body: "job"
    70          };
    71      };
    72  
    73      rpc GetJob(GetJobRequest) returns (Job){
    74          option (google.api.http) = {
    75              get: "/api/v1/jobs/{id=*}"
    76          };
    77      };
    78  
    79      rpc ListJobs(ListJobsRequest) returns (ListJobsResponse){
    80          option (google.api.http) = {
    81              get: "/api/v1/jobs"
    82          };
    83      };
    84  
    85      // NOTE: for the compatibility of existing openapi(ticdc) format,
    86      // we use `/cancel` but not `:cancel`(google api suggested)
    87      // refer to: https://cloud.google.com/apis/design/custom_methods
    88      rpc CancelJob(CancelJobRequest) returns (Job){
    89          option (google.api.http) = {
    90              post: "/api/v1/jobs/{id=*}/cancel"
    91          };
    92      };
    93  
    94      rpc DeleteJob(DeleteJobRequest) returns (google.protobuf.Empty){
    95          option (google.api.http) = {
    96              delete: "/api/v1/jobs/{id=*}"
    97          };
    98      }
    99  }
   100  
   101  message Selector {
   102      enum Op {
   103          OpUnknown = 0;
   104          Eq = 1;
   105          Neq = 2;
   106          Regex = 3;
   107      }
   108  
   109      string label = 1;
   110      string target = 2;
   111      Op op = 3;
   112  }
   113  
   114  message HeartbeatRequest {
   115      string executor_id = 1;
   116      uint64 timestamp = 2;
   117      uint64 ttl = 3;
   118  }
   119  
   120  message HeartbeatResponse {
   121  }
   122  
   123  message Executor {
   124      string id = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
   125      // name is the readable name of the executor.
   126      string name = 2;
   127      string address = 3;
   128      map<string, string> labels = 4;
   129  }
   130  
   131  message RegisterExecutorRequest {
   132      Executor executor = 1;
   133  }
   134  
   135  message ListExecutorsRequest {
   136  }
   137  
   138  message ListExecutorsResponse {
   139      repeated Executor executors = 1;
   140  }
   141  
   142  message Master {
   143      string id = 1;
   144      // name is the readable name of the master.
   145      string name = 2;
   146      string address = 3;
   147      bool is_leader = 4;
   148  }
   149  
   150  message ListMastersRequest {
   151  }
   152  
   153  message ListMastersResponse {
   154      repeated Master masters = 1;
   155  }
   156  
   157  
   158  message ScheduleTaskRequest {
   159      string task_id = 1;
   160      // resources required by the task.
   161      repeated ResourceKey resources = 2;
   162      repeated Selector selectors = 3;
   163  }
   164  
   165  message ScheduleTaskResponse {
   166      string executor_id = 1;
   167      string executor_addr = 2;
   168  }
   169  
   170  message GetLeaderRequest {
   171  }
   172  
   173  message GetLeaderResponse {
   174      string advertise_addr = 1;
   175  }
   176  
   177  message ResignLeaderRequest {
   178  }
   179  
   180  message Job {
   181      enum Type {
   182          TypeUnknown = 0;
   183          CVSDemo = 1;
   184          DM = 2;
   185          CDC = 3;
   186          FakeJob = 4;
   187      }
   188  
   189      enum State{
   190          StateUnknown = 0;
   191          Created = 1;
   192          Running = 2;
   193          Failed = 3;
   194          Finished = 4;
   195          Canceling = 5;
   196          Canceled = 6;
   197      }
   198  
   199      message Error {
   200          string code = 1;
   201          string message = 2;
   202      }
   203  
   204      string id = 1;
   205      Type type = 2;
   206      State state = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
   207      // Output will ignore this field by default unless include_config is set to true.
   208      bytes config = 4;
   209      bytes detail = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
   210      Error error = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
   211      repeated Selector selectors = 7;
   212  }
   213  
   214  message CreateJobRequest {
   215      Job job = 1;
   216      string tenant_id = 2;
   217      string project_id = 3;
   218  }
   219  
   220  message GetJobRequest {
   221      string id = 1;
   222      string tenant_id = 2;
   223      string project_id = 3;
   224      // Whether to return the config of the job.
   225      // Config may contain sensitive information, it is not returned by default.
   226      bool include_config = 4;
   227  }
   228  
   229  message ListJobsRequest {
   230      // The maximum number of jobs to return.
   231      // If it is unspecified or less than 1, at most 100 jobs will be returned.
   232      // The maximum value is 1000. Larger values will be coerced to 1000.
   233      int32 page_size = 1;
   234      // The page token, returned by a previous call, to request the next page of results.
   235      string page_token = 2;
   236      string tenant_id = 3;
   237      string project_id = 4;
   238      // Whether to return the config of the job.
   239      // Config may contain sensitive information, it is not returned by default.
   240      bool include_config = 5;
   241      Job.Type type = 6;
   242      Job.State state = 7;
   243  }
   244  
   245  message ListJobsResponse {
   246      repeated Job jobs = 1;
   247      // A token to retrieve next page of results.
   248      // If this field is empty, it means no more pages.
   249      string next_page_token = 2;
   250  }
   251  
   252  message CancelJobRequest {
   253      string id = 1;
   254      string tenant_id = 2;
   255      string project_id = 3;
   256  }
   257  
   258  message DeleteJobRequest {
   259      string id = 1;
   260      string tenant_id = 2;
   261      string project_id = 3;
   262  }
   263  
   264  enum StoreType {
   265      SystemMetaStore = 0;
   266      AppMetaStore = 1;
   267  }
   268  
   269  message QueryMetaStoreRequest {
   270      StoreType tp = 1;
   271  }
   272  
   273  message QueryMetaStoreResponse {
   274      bytes config = 1;
   275  }
   276  
   277  message QueryStorageConfigRequest {
   278  }
   279  
   280  message QueryStorageConfigResponse {
   281      bytes config = 2;
   282  }