vitess-gh/proto/workflow.proto

113 строки
3.7 KiB
Protocol Buffer

/*
Copyright 2019 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file contains the Vitess workflow management related data
// structures. They are used to store / retrieve state from topology
// server.
syntax = "proto3";
option go_package = "vitess.io/vitess/go/vt/proto/workflow";
package workflow;
// WorkflowState describes the state of a workflow.
// This constant should match the Node object described in
// web/vtctld2/src/app/workflows/node.ts as it is exposed as JSON to
// the Angular 2 web app.
enum WorkflowState {
NotStarted = 0;
Running = 1;
Done = 2;
}
// Workflow is the persisted state of a long-running workflow.
message Workflow {
// uuid is set when the workflow is created, and immutable after
// that.
string uuid = 1;
// factory_name is set with the name of the factory that created the
// job (and can also restart it). It is set at creation time, and
// immutable after that.
string factory_name = 2;
// name is the display name of the workflow.
string name = 3;
// state describes the state of the job. A job is created as
// NotStarted, then the Workflow Manager picks it up and starts it,
// switching it to Running (and populating 'start_time'). The
// workflow can then fail over to a new Workflow Manager is
// necessary, and still be in Running state. When done, it goes to
// Done, 'end_time' is populated, and 'error' is set if there was an
// error.
WorkflowState state = 4;
// data is workflow-specific stored data. It is usually a binary
// proto-encoded data structure. It can vary throughout the
// execution of the workflow. It will not change after the workflow
// is Done.
bytes data = 5;
// error is set if the job finished with an error. This field only
// makes sense if 'state' is Done.
string error = 6;
// start_time is set when the workflow manager starts a workflow for
// the first time. This field only makes sense if 'state' is Running
// or Done.
int64 start_time = 7;
// end_time is set when the workflow is finished.
// This field only makes sense if 'state' is Done.
int64 end_time = 8;
// create_time is set when the workflow is created.
int64 create_time = 9;
}
message WorkflowCheckpoint {
// code_version is used to detect incompabilities between the version of the
// running workflow and the one which wrote the checkpoint. If they don't
// match, the workflow must not continue. The author of workflow must update
// this variable in their implementation when incompabilities are introduced.
int32 code_version = 1;
// tasks stores all tasks of the workflow in a map. The key is a unique name
// to identify the task, e.g. clone/-80.
// Task is the data structure that stores the execution status and the
// attributes of a task.
map<string, Task> tasks = 2;
// settings includes workflow specific data, e.g. the resharding workflow
// would store the source shards and destination shards.
map<string, string> settings = 3;
}
enum TaskState {
TaskNotStarted = 0;
TaskRunning = 1;
TaskDone = 2;
}
message Task {
string id = 1;
TaskState state = 2;
// attributes includes the parameters the task needs.
map<string, string> attributes = 3;
string error = 4;
}