Files
saasapi/cmd.proto
2025-05-21 17:06:32 +08:00

224 lines
9.8 KiB
Protocol Buffer
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
syntax = "proto3";
package saasapi;
option go_package = "e.coding.net/rta/public/saasapi";
// SaasReq 命令请求
message SaasReq {
oneof cmd {
Read read = 10; // 批量读取
Write write = 11; // 批量写入
ColumnWrite column_write = 12; // 全量列式写入
Task task_create = 20; // 任务创建
TaskList task_list = 21; // 列出任务
TaskRun task_run = 22; // 执行任务
TaskDelete task_delete = 23; // 删除任务
TaskInfo task_info = 24; // 任务详情
}
}
// Read 批量读取命令
message Read {
string dataspace_id = 1; // 数据空间ID
string appid = 2; // 小程序/小游戏/公众号/视频号的appid
repeated ReadItem read_items = 3; // 批量获取命令
}
// ReadItem 读取命令
message ReadItem {
string userid = 1; // 用户ID
}
// Write 批量写入命令
message Write {
string dataspace_id = 1; // 数据空间ID
string appid = 2; // 小程序/小游戏/公众号/视频号的appid
bool is_clear_all_first = 3; // 是否先清空该用户所有数据
repeated WriteItem write_items = 4; // 批量写入命令
}
// WriteItem 写入命令
message WriteItem {
string userid = 1; // 用户ID
Bytes write_bytes = 2; // byte区域
Uint32s write_uint32s = 3; // uint32区域
FlagsWithExpire write_flags_with_expire = 4; // 标志位区域
}
// Bytes 写入byte区域
message Bytes {
bytes bytes = 1; // 写入的byte
uint64 index_1 = 2; // 写入byte的索引值(0..63)
uint64 index_2 = 3; // 写入byte的索引值(64..127)
}
// Uint32s 写入uint32区域
message Uint32s {
repeated uint32 uint32s = 1; // 写入的uint32
uint64 index_1 = 2; // 写入uint32的索引值(0..15) 最多 16 个
//uint64 index_2 = 3; // 写入uint32的索引值(当前不支持)
}
// FlagsWithExpire 写入标志位区域
message FlagsWithExpire {
repeated FlagWithExpire flags_with_expire = 1; // 写入的标志位
uint64 index_1 = 2; // 写入标志位的索引值
}
// FlagWithExpire 标志位
message FlagWithExpire {
bool flag = 1; // 标志位
bool default_flag = 2; // 默认值。超时后则回到默认值。
uint32 expire = 3; // 过期时间,为 0 则永不过期
}
// ColumnWrite 全量列式写入命令
message ColumnWrite {
string dataspace_id = 1; // 数据空间ID
bool is_clear_all_first = 2; // 是否先执行清空
Bytes write_bytes = 3; // byte区域
Uint32s write_uint32s = 4; // uint32区域
FlagsWithExpire write_flags_with_expire = 5; // 标志位区域
}
message Task {
string dataspace_id = 1; // 数据空间ID
string appid = 2; // 小程序/小游戏/公众号/视频号的appid
string task_sha256 = 3; // 任务sha256
string task_description = 4; // 任务描述
repeated FileInfo task_file_infos = 5; // 文件列表
uint64 task_block_size = 6; // 文件块字节大小推荐200M
// 以下字段只在返回时填写,用于提供服务端的任务状态。在请求时填写会被忽略
string create_time = 10; // 创建时间
string run_time = 11; // 运行时间
string finish_time = 12; // 完成时间
TaskStatus status = 15; // 任务状态
}
// TaskList 任务列表
message TaskList {
TaskStatus status_filter = 1; // 只显示指定状态的任务
}
// TaskRun 任务运行
message TaskRun {
string task_sha256 = 1; // 任务sha256
}
// TaskDelete 取消任务
message TaskDelete {
string task_sha256 = 1; // 任务sha256
}
// TaskInfo 任务详情
message TaskInfo {
string task_sha256 = 1; // 任务sha256
}
message FileInfo {
string file_name = 1; // 文件名
uint64 file_size = 2; // 文件大小
repeated FileBlock file_blocks = 3; // 文件块列表
}
message FileBlock {
string block_sha256 = 1; // 块的sha256
uint64 block_length = 2; // 块的字节长度
bool uploaded = 3; // 是否已上传在TaskCreate/TaskInfo请求返回
}
// SaasRes 命令返回
message SaasRes {
ErrorCode code = 1; // 返回码
string status = 2; // 返回信息的文本提示
oneof res {
ReadRes read_res = 10; // 读取命令返回
WriteRes write_res = 11; // 写入命令返回
Task task_create_res = 20; // 创建任务返回状态
TaskListRes task_list_res = 21; // 任务列表返回状态
Task task_run_res = 22; // 运行任务返回状态
Task task_delete_res = 23; // 删除任务返回状态
Task task_info_res = 24; // 任务详情返回状态
}
}
message ReadRes {
uint32 succ_cmd_count = 1; // 成功的命令数量
uint32 fail_cmd_count = 2; // 失败的命令数量
repeated ValueItem cmd_res = 3; // 返回的命令
}
message WriteRes {
//uint32 succ_cmd_count = 1; // 成功的命令数量
//uint32 fail_cmd_count = 2; // 失败的命令数量
repeated string failed_userid = 3; // 返回的失败的用户ID
}
// ValueItem 读取命令返回内容
message ValueItem {
uint32 cmd_index = 1; // 命令索引
CmdErrorCode cmd_code = 2; // 状态
bytes bytes = 3; // byte区域
repeated uint32 uint32s = 4; // uint32区域
repeated FlagWithExpire flags_with_expire = 5; // 标志位区域
uint32 last_modify_time = 6; // 最后修改时间
}
message TaskListRes {
repeated Task tasks = 1; // 任务列表
}
// ErrorCode 返回码
enum ErrorCode {
SUCC = 0; // 成功
INVALID_ACCOUNT = 101; // Account不合法
INVALID_TIMESTAMP = 102; // 头信息缺少时间戳或不正确
INVALID_SIGNATURE = 103; // 头信息缺少签名
AUTH_FAIL = 104; // 签名较验失败
DISABLED_ACCOUNT = 105; // 账号已禁用
INVALID_CONTENT_TYPE = 110; // 非法的Content-Type
READ_BODY = 111; // 读取 http body 失败
DECODE_BODY = 112; // 解码 body 失败
QPS_LIMIT = 113; // 并发请求量超限
CMDS_LIMIT = 114; // 命令数量超限
CMDS_NULL = 115; // 命令为空
DATASPACE_NOT_EXISTS = 116; // 数据空间不存在
TASK_EXISTS = 120; // 任务已存在
TASK_IS_NOT_EXISTS = 121; // 任务不存在
TASK_NUM_LIMIT = 122; // 任务数达到上限
TASK_BLOCK_SIZE = 123; // 块大小超限
TASK_TOTAL_SIZE = 124; // 总文件大小超限
TASK_MARSHAL = 125; // 序列化
TASK_IS_WATING = 130; // 任务未上传完毕
TASK_IS_RUNNING = 131; // 任务已经在运行
TASK_FAILED = 132; // 任务已失败
TASK_FINISHED = 133; // 任务已完成
DATA_ERROR = 201; // 数据错误
CMD_ERROR = 202; // 命令行执行错误
}
enum CmdErrorCode {
OK = 0; // 成功
}
enum TaskStatus {
ALL = 0; // 全部
WAITING = 1; // 等待中
READY = 2; // 上传完毕
RUNNING = 3; // 运行中
SUCCESS = 4; // 成功
FAIL = 5; // 失败
DELETED = 10; // 已删除,仅在执行删除成功时返回
}