为task增加sourcepath,便于处理

This commit is contained in:
algotao
2025-07-25 12:04:16 +08:00
parent d1ad148725
commit a2bf3c853e
5 changed files with 303 additions and 63 deletions

326
cmd.pb.go
View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.36.6 // protoc-gen-go v1.36.6
// protoc v4.24.4 // protoc v5.29.4
// source: cmd.proto // source: cmd.proto
package saasapi package saasapi
@@ -254,6 +254,7 @@ type SaasReq struct {
// *SaasReq_TaskRun // *SaasReq_TaskRun
// *SaasReq_TaskDelete // *SaasReq_TaskDelete
// *SaasReq_TaskInfo // *SaasReq_TaskInfo
// *SaasReq_Debug
Cmd isSaasReq_Cmd `protobuf_oneof:"cmd"` Cmd isSaasReq_Cmd `protobuf_oneof:"cmd"`
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -368,6 +369,15 @@ func (x *SaasReq) GetTaskInfo() *TaskInfo {
return nil return nil
} }
func (x *SaasReq) GetDebug() *Debug {
if x != nil {
if x, ok := x.Cmd.(*SaasReq_Debug); ok {
return x.Debug
}
}
return nil
}
type isSaasReq_Cmd interface { type isSaasReq_Cmd interface {
isSaasReq_Cmd() isSaasReq_Cmd()
} }
@@ -404,6 +414,10 @@ type SaasReq_TaskInfo struct {
TaskInfo *TaskInfo `protobuf:"bytes,24,opt,name=task_info,json=taskInfo,proto3,oneof"` // 任务详情 TaskInfo *TaskInfo `protobuf:"bytes,24,opt,name=task_info,json=taskInfo,proto3,oneof"` // 任务详情
} }
type SaasReq_Debug struct {
Debug *Debug `protobuf:"bytes,30,opt,name=debug,proto3,oneof"` // 试运行lua脚本
}
func (*SaasReq_Read) isSaasReq_Cmd() {} func (*SaasReq_Read) isSaasReq_Cmd() {}
func (*SaasReq_Write) isSaasReq_Cmd() {} func (*SaasReq_Write) isSaasReq_Cmd() {}
@@ -420,6 +434,8 @@ func (*SaasReq_TaskDelete) isSaasReq_Cmd() {}
func (*SaasReq_TaskInfo) isSaasReq_Cmd() {} func (*SaasReq_TaskInfo) isSaasReq_Cmd() {}
func (*SaasReq_Debug) isSaasReq_Cmd() {}
// Read 批量读取命令 // Read 批量读取命令
type Read struct { type Read struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
@@ -977,6 +993,8 @@ type Task struct {
TaskDescription string `protobuf:"bytes,4,opt,name=task_description,json=taskDescription,proto3" json:"task_description,omitempty"` // 任务描述 TaskDescription string `protobuf:"bytes,4,opt,name=task_description,json=taskDescription,proto3" json:"task_description,omitempty"` // 任务描述
TaskFileInfos []*FileInfo `protobuf:"bytes,5,rep,name=task_file_infos,json=taskFileInfos,proto3" json:"task_file_infos,omitempty"` // 文件列表 TaskFileInfos []*FileInfo `protobuf:"bytes,5,rep,name=task_file_infos,json=taskFileInfos,proto3" json:"task_file_infos,omitempty"` // 文件列表
TaskBlockSize uint64 `protobuf:"varint,6,opt,name=task_block_size,json=taskBlockSize,proto3" json:"task_block_size,omitempty"` // 文件块字节大小推荐200M TaskBlockSize uint64 `protobuf:"varint,6,opt,name=task_block_size,json=taskBlockSize,proto3" json:"task_block_size,omitempty"` // 文件块字节大小推荐200M
SourcePath string `protobuf:"bytes,7,opt,name=source_path,json=sourcePath,proto3" json:"source_path,omitempty"` // 任务数据源路径
TaskSize uint64 `protobuf:"varint,8,opt,name=task_size,json=taskSize,proto3" json:"task_size,omitempty"` // 任务所有文件的总大小
// 以下字段只在返回时填写,用于提供服务端的任务状态。在请求时填写会被忽略 // 以下字段只在返回时填写,用于提供服务端的任务状态。在请求时填写会被忽略
CreateTime string `protobuf:"bytes,10,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` // 创建时间 CreateTime string `protobuf:"bytes,10,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` // 创建时间
RunTime string `protobuf:"bytes,11,opt,name=run_time,json=runTime,proto3" json:"run_time,omitempty"` // 运行时间 RunTime string `protobuf:"bytes,11,opt,name=run_time,json=runTime,proto3" json:"run_time,omitempty"` // 运行时间
@@ -1058,6 +1076,20 @@ func (x *Task) GetTaskBlockSize() uint64 {
return 0 return 0
} }
func (x *Task) GetSourcePath() string {
if x != nil {
return x.SourcePath
}
return ""
}
func (x *Task) GetTaskSize() uint64 {
if x != nil {
return x.TaskSize
}
return 0
}
func (x *Task) GetCreateTime() string { func (x *Task) GetCreateTime() string {
if x != nil { if x != nil {
return x.CreateTime return x.CreateTime
@@ -1386,6 +1418,98 @@ func (x *FileBlock) GetUploaded() bool {
return false return false
} }
type Debug struct {
state protoimpl.MessageState `protogen:"open.v1"`
LuaScript string `protobuf:"bytes,1,opt,name=lua_script,json=luaScript,proto3" json:"lua_script,omitempty"` // 要调试的lua脚本
UseServerData bool `protobuf:"varint,2,opt,name=use_server_data,json=useServerData,proto3" json:"use_server_data,omitempty"` // 是否使用服务端用户数据
ServerDid string `protobuf:"bytes,3,opt,name=server_did,json=serverDid,proto3" json:"server_did,omitempty"` // 将从服务端读取该DID下的数据
Appid string `protobuf:"bytes,4,opt,name=appid,proto3" json:"appid,omitempty"` // 小程序/小游戏/公众号/视频号的appid
ServerOpenid string `protobuf:"bytes,5,opt,name=server_openid,json=serverOpenid,proto3" json:"server_openid,omitempty"` // 将从服务端读取该openid下的数据需与appid配对使用
LocalDidData *WriteItem `protobuf:"bytes,6,opt,name=local_did_data,json=localDidData,proto3" json:"local_did_data,omitempty"` // 客户自定义DID用户数据
LocalOpenidData *WriteItem `protobuf:"bytes,7,opt,name=local_openid_data,json=localOpenidData,proto3" json:"local_openid_data,omitempty"` // 客户定定义OpenID用户数据
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Debug) Reset() {
*x = Debug{}
mi := &file_cmd_proto_msgTypes[17]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Debug) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Debug) ProtoMessage() {}
func (x *Debug) ProtoReflect() protoreflect.Message {
mi := &file_cmd_proto_msgTypes[17]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Debug.ProtoReflect.Descriptor instead.
func (*Debug) Descriptor() ([]byte, []int) {
return file_cmd_proto_rawDescGZIP(), []int{17}
}
func (x *Debug) GetLuaScript() string {
if x != nil {
return x.LuaScript
}
return ""
}
func (x *Debug) GetUseServerData() bool {
if x != nil {
return x.UseServerData
}
return false
}
func (x *Debug) GetServerDid() string {
if x != nil {
return x.ServerDid
}
return ""
}
func (x *Debug) GetAppid() string {
if x != nil {
return x.Appid
}
return ""
}
func (x *Debug) GetServerOpenid() string {
if x != nil {
return x.ServerOpenid
}
return ""
}
func (x *Debug) GetLocalDidData() *WriteItem {
if x != nil {
return x.LocalDidData
}
return nil
}
func (x *Debug) GetLocalOpenidData() *WriteItem {
if x != nil {
return x.LocalOpenidData
}
return nil
}
// SaasRes 命令返回 // SaasRes 命令返回
type SaasRes struct { type SaasRes struct {
state protoimpl.MessageState `protogen:"open.v1"` state protoimpl.MessageState `protogen:"open.v1"`
@@ -1407,7 +1531,7 @@ type SaasRes struct {
func (x *SaasRes) Reset() { func (x *SaasRes) Reset() {
*x = SaasRes{} *x = SaasRes{}
mi := &file_cmd_proto_msgTypes[17] mi := &file_cmd_proto_msgTypes[18]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -1419,7 +1543,7 @@ func (x *SaasRes) String() string {
func (*SaasRes) ProtoMessage() {} func (*SaasRes) ProtoMessage() {}
func (x *SaasRes) ProtoReflect() protoreflect.Message { func (x *SaasRes) ProtoReflect() protoreflect.Message {
mi := &file_cmd_proto_msgTypes[17] mi := &file_cmd_proto_msgTypes[18]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -1432,7 +1556,7 @@ func (x *SaasRes) ProtoReflect() protoreflect.Message {
// Deprecated: Use SaasRes.ProtoReflect.Descriptor instead. // Deprecated: Use SaasRes.ProtoReflect.Descriptor instead.
func (*SaasRes) Descriptor() ([]byte, []int) { func (*SaasRes) Descriptor() ([]byte, []int) {
return file_cmd_proto_rawDescGZIP(), []int{17} return file_cmd_proto_rawDescGZIP(), []int{18}
} }
func (x *SaasRes) GetCode() ErrorCode { func (x *SaasRes) GetCode() ErrorCode {
@@ -1576,7 +1700,7 @@ type ReadRes struct {
func (x *ReadRes) Reset() { func (x *ReadRes) Reset() {
*x = ReadRes{} *x = ReadRes{}
mi := &file_cmd_proto_msgTypes[18] mi := &file_cmd_proto_msgTypes[19]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -1588,7 +1712,7 @@ func (x *ReadRes) String() string {
func (*ReadRes) ProtoMessage() {} func (*ReadRes) ProtoMessage() {}
func (x *ReadRes) ProtoReflect() protoreflect.Message { func (x *ReadRes) ProtoReflect() protoreflect.Message {
mi := &file_cmd_proto_msgTypes[18] mi := &file_cmd_proto_msgTypes[19]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -1601,7 +1725,7 @@ func (x *ReadRes) ProtoReflect() protoreflect.Message {
// Deprecated: Use ReadRes.ProtoReflect.Descriptor instead. // Deprecated: Use ReadRes.ProtoReflect.Descriptor instead.
func (*ReadRes) Descriptor() ([]byte, []int) { func (*ReadRes) Descriptor() ([]byte, []int) {
return file_cmd_proto_rawDescGZIP(), []int{18} return file_cmd_proto_rawDescGZIP(), []int{19}
} }
func (x *ReadRes) GetSuccCmdCount() uint32 { func (x *ReadRes) GetSuccCmdCount() uint32 {
@@ -1636,7 +1760,7 @@ type WriteRes struct {
func (x *WriteRes) Reset() { func (x *WriteRes) Reset() {
*x = WriteRes{} *x = WriteRes{}
mi := &file_cmd_proto_msgTypes[19] mi := &file_cmd_proto_msgTypes[20]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -1648,7 +1772,7 @@ func (x *WriteRes) String() string {
func (*WriteRes) ProtoMessage() {} func (*WriteRes) ProtoMessage() {}
func (x *WriteRes) ProtoReflect() protoreflect.Message { func (x *WriteRes) ProtoReflect() protoreflect.Message {
mi := &file_cmd_proto_msgTypes[19] mi := &file_cmd_proto_msgTypes[20]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -1661,7 +1785,7 @@ func (x *WriteRes) ProtoReflect() protoreflect.Message {
// Deprecated: Use WriteRes.ProtoReflect.Descriptor instead. // Deprecated: Use WriteRes.ProtoReflect.Descriptor instead.
func (*WriteRes) Descriptor() ([]byte, []int) { func (*WriteRes) Descriptor() ([]byte, []int) {
return file_cmd_proto_rawDescGZIP(), []int{19} return file_cmd_proto_rawDescGZIP(), []int{20}
} }
func (x *WriteRes) GetFailedUserid() []string { func (x *WriteRes) GetFailedUserid() []string {
@@ -1686,7 +1810,7 @@ type ValueItem struct {
func (x *ValueItem) Reset() { func (x *ValueItem) Reset() {
*x = ValueItem{} *x = ValueItem{}
mi := &file_cmd_proto_msgTypes[20] mi := &file_cmd_proto_msgTypes[21]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -1698,7 +1822,7 @@ func (x *ValueItem) String() string {
func (*ValueItem) ProtoMessage() {} func (*ValueItem) ProtoMessage() {}
func (x *ValueItem) ProtoReflect() protoreflect.Message { func (x *ValueItem) ProtoReflect() protoreflect.Message {
mi := &file_cmd_proto_msgTypes[20] mi := &file_cmd_proto_msgTypes[21]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -1711,7 +1835,7 @@ func (x *ValueItem) ProtoReflect() protoreflect.Message {
// Deprecated: Use ValueItem.ProtoReflect.Descriptor instead. // Deprecated: Use ValueItem.ProtoReflect.Descriptor instead.
func (*ValueItem) Descriptor() ([]byte, []int) { func (*ValueItem) Descriptor() ([]byte, []int) {
return file_cmd_proto_rawDescGZIP(), []int{20} return file_cmd_proto_rawDescGZIP(), []int{21}
} }
func (x *ValueItem) GetCmdIndex() uint32 { func (x *ValueItem) GetCmdIndex() uint32 {
@@ -1765,7 +1889,7 @@ type TaskListRes struct {
func (x *TaskListRes) Reset() { func (x *TaskListRes) Reset() {
*x = TaskListRes{} *x = TaskListRes{}
mi := &file_cmd_proto_msgTypes[21] mi := &file_cmd_proto_msgTypes[22]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi) ms.StoreMessageInfo(mi)
} }
@@ -1777,7 +1901,7 @@ func (x *TaskListRes) String() string {
func (*TaskListRes) ProtoMessage() {} func (*TaskListRes) ProtoMessage() {}
func (x *TaskListRes) ProtoReflect() protoreflect.Message { func (x *TaskListRes) ProtoReflect() protoreflect.Message {
mi := &file_cmd_proto_msgTypes[21] mi := &file_cmd_proto_msgTypes[22]
if x != nil { if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil { if ms.LoadMessageInfo() == nil {
@@ -1790,7 +1914,7 @@ func (x *TaskListRes) ProtoReflect() protoreflect.Message {
// Deprecated: Use TaskListRes.ProtoReflect.Descriptor instead. // Deprecated: Use TaskListRes.ProtoReflect.Descriptor instead.
func (*TaskListRes) Descriptor() ([]byte, []int) { func (*TaskListRes) Descriptor() ([]byte, []int) {
return file_cmd_proto_rawDescGZIP(), []int{21} return file_cmd_proto_rawDescGZIP(), []int{22}
} }
func (x *TaskListRes) GetTasks() []*Task { func (x *TaskListRes) GetTasks() []*Task {
@@ -1800,11 +1924,71 @@ func (x *TaskListRes) GetTasks() []*Task {
return nil return nil
} }
type DebugRes struct {
state protoimpl.MessageState `protogen:"open.v1"`
PrintOutput string `protobuf:"bytes,1,opt,name=PrintOutput,proto3" json:"PrintOutput,omitempty"` // print输出
Error string `protobuf:"bytes,2,opt,name=Error,proto3" json:"Error,omitempty"` // 错误信息
TargetsOutput string `protobuf:"bytes,3,opt,name=TargetsOutput,proto3" json:"TargetsOutput,omitempty"` // 策略输出
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *DebugRes) Reset() {
*x = DebugRes{}
mi := &file_cmd_proto_msgTypes[23]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *DebugRes) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DebugRes) ProtoMessage() {}
func (x *DebugRes) ProtoReflect() protoreflect.Message {
mi := &file_cmd_proto_msgTypes[23]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DebugRes.ProtoReflect.Descriptor instead.
func (*DebugRes) Descriptor() ([]byte, []int) {
return file_cmd_proto_rawDescGZIP(), []int{23}
}
func (x *DebugRes) GetPrintOutput() string {
if x != nil {
return x.PrintOutput
}
return ""
}
func (x *DebugRes) GetError() string {
if x != nil {
return x.Error
}
return ""
}
func (x *DebugRes) GetTargetsOutput() string {
if x != nil {
return x.TargetsOutput
}
return ""
}
var File_cmd_proto protoreflect.FileDescriptor var File_cmd_proto protoreflect.FileDescriptor
const file_cmd_proto_rawDesc = "" + const file_cmd_proto_rawDesc = "" +
"\n" + "\n" +
"\tcmd.proto\x12\asaasapi\"\x95\x03\n" + "\tcmd.proto\x12\asaasapi\"\xbd\x03\n" +
"\aSaasReq\x12#\n" + "\aSaasReq\x12#\n" +
"\x04read\x18\n" + "\x04read\x18\n" +
" \x01(\v2\r.saasapi.ReadH\x00R\x04read\x12&\n" + " \x01(\v2\r.saasapi.ReadH\x00R\x04read\x12&\n" +
@@ -1816,7 +2000,8 @@ const file_cmd_proto_rawDesc = "" +
"\btask_run\x18\x16 \x01(\v2\x10.saasapi.TaskRunH\x00R\ataskRun\x126\n" + "\btask_run\x18\x16 \x01(\v2\x10.saasapi.TaskRunH\x00R\ataskRun\x126\n" +
"\vtask_delete\x18\x17 \x01(\v2\x13.saasapi.TaskDeleteH\x00R\n" + "\vtask_delete\x18\x17 \x01(\v2\x13.saasapi.TaskDeleteH\x00R\n" +
"taskDelete\x120\n" + "taskDelete\x120\n" +
"\ttask_info\x18\x18 \x01(\v2\x11.saasapi.TaskInfoH\x00R\btaskInfoB\x05\n" + "\ttask_info\x18\x18 \x01(\v2\x11.saasapi.TaskInfoH\x00R\btaskInfo\x12&\n" +
"\x05debug\x18\x1e \x01(\v2\x0e.saasapi.DebugH\x00R\x05debugB\x05\n" +
"\x03cmd\"q\n" + "\x03cmd\"q\n" +
"\x04Read\x12!\n" + "\x04Read\x12!\n" +
"\fdataspace_id\x18\x01 \x01(\tR\vdataspaceId\x12\x14\n" + "\fdataspace_id\x18\x01 \x01(\tR\vdataspaceId\x12\x14\n" +
@@ -1857,7 +2042,7 @@ const file_cmd_proto_rawDesc = "" +
"\vwrite_bytes\x18\x03 \x01(\v2\x0e.saasapi.BytesR\n" + "\vwrite_bytes\x18\x03 \x01(\v2\x0e.saasapi.BytesR\n" +
"writeBytes\x125\n" + "writeBytes\x125\n" +
"\rwrite_uint32s\x18\x04 \x01(\v2\x10.saasapi.Uint32sR\fwriteUint32s\x12O\n" + "\rwrite_uint32s\x18\x04 \x01(\v2\x10.saasapi.Uint32sR\fwriteUint32s\x12O\n" +
"\x17write_flags_with_expire\x18\x05 \x01(\v2\x18.saasapi.FlagsWithExpireR\x14writeFlagsWithExpire\"\xf8\x02\n" + "\x17write_flags_with_expire\x18\x05 \x01(\v2\x18.saasapi.FlagsWithExpireR\x14writeFlagsWithExpire\"\xb6\x03\n" +
"\x04Task\x12!\n" + "\x04Task\x12!\n" +
"\fdataspace_id\x18\x01 \x01(\tR\vdataspaceId\x12\x14\n" + "\fdataspace_id\x18\x01 \x01(\tR\vdataspaceId\x12\x14\n" +
"\x05appid\x18\x02 \x01(\tR\x05appid\x12\x1f\n" + "\x05appid\x18\x02 \x01(\tR\x05appid\x12\x1f\n" +
@@ -1866,6 +2051,9 @@ const file_cmd_proto_rawDesc = "" +
"\x10task_description\x18\x04 \x01(\tR\x0ftaskDescription\x129\n" + "\x10task_description\x18\x04 \x01(\tR\x0ftaskDescription\x129\n" +
"\x0ftask_file_infos\x18\x05 \x03(\v2\x11.saasapi.FileInfoR\rtaskFileInfos\x12&\n" + "\x0ftask_file_infos\x18\x05 \x03(\v2\x11.saasapi.FileInfoR\rtaskFileInfos\x12&\n" +
"\x0ftask_block_size\x18\x06 \x01(\x04R\rtaskBlockSize\x12\x1f\n" + "\x0ftask_block_size\x18\x06 \x01(\x04R\rtaskBlockSize\x12\x1f\n" +
"\vsource_path\x18\a \x01(\tR\n" +
"sourcePath\x12\x1b\n" +
"\ttask_size\x18\b \x01(\x04R\btaskSize\x12\x1f\n" +
"\vcreate_time\x18\n" + "\vcreate_time\x18\n" +
" \x01(\tR\n" + " \x01(\tR\n" +
"createTime\x12\x19\n" + "createTime\x12\x19\n" +
@@ -1893,7 +2081,17 @@ const file_cmd_proto_rawDesc = "" +
"\tFileBlock\x12!\n" + "\tFileBlock\x12!\n" +
"\fblock_sha256\x18\x01 \x01(\tR\vblockSha256\x12!\n" + "\fblock_sha256\x18\x01 \x01(\tR\vblockSha256\x12!\n" +
"\fblock_length\x18\x02 \x01(\x04R\vblockLength\x12\x1a\n" + "\fblock_length\x18\x02 \x01(\x04R\vblockLength\x12\x1a\n" +
"\buploaded\x18\x03 \x01(\bR\buploaded\"\xc7\x03\n" + "\buploaded\x18\x03 \x01(\bR\buploaded\"\xa2\x02\n" +
"\x05Debug\x12\x1d\n" +
"\n" +
"lua_script\x18\x01 \x01(\tR\tluaScript\x12&\n" +
"\x0fuse_server_data\x18\x02 \x01(\bR\ruseServerData\x12\x1d\n" +
"\n" +
"server_did\x18\x03 \x01(\tR\tserverDid\x12\x14\n" +
"\x05appid\x18\x04 \x01(\tR\x05appid\x12#\n" +
"\rserver_openid\x18\x05 \x01(\tR\fserverOpenid\x128\n" +
"\x0elocal_did_data\x18\x06 \x01(\v2\x12.saasapi.WriteItemR\flocalDidData\x12>\n" +
"\x11local_openid_data\x18\a \x01(\v2\x12.saasapi.WriteItemR\x0flocalOpenidData\"\xc7\x03\n" +
"\aSaasRes\x12&\n" + "\aSaasRes\x12&\n" +
"\x04code\x18\x01 \x01(\x0e2\x12.saasapi.ErrorCodeR\x04code\x12\x16\n" + "\x04code\x18\x01 \x01(\x0e2\x12.saasapi.ErrorCodeR\x04code\x12\x16\n" +
"\x06status\x18\x02 \x01(\tR\x06status\x12-\n" + "\x06status\x18\x02 \x01(\tR\x06status\x12-\n" +
@@ -1921,7 +2119,11 @@ const file_cmd_proto_rawDesc = "" +
"\x11flags_with_expire\x18\x05 \x03(\v2\x17.saasapi.FlagWithExpireR\x0fflagsWithExpire\x12(\n" + "\x11flags_with_expire\x18\x05 \x03(\v2\x17.saasapi.FlagWithExpireR\x0fflagsWithExpire\x12(\n" +
"\x10last_modify_time\x18\x06 \x01(\rR\x0elastModifyTime\"2\n" + "\x10last_modify_time\x18\x06 \x01(\rR\x0elastModifyTime\"2\n" +
"\vTaskListRes\x12#\n" + "\vTaskListRes\x12#\n" +
"\x05tasks\x18\x01 \x03(\v2\r.saasapi.TaskR\x05tasks*\xea\x03\n" + "\x05tasks\x18\x01 \x03(\v2\r.saasapi.TaskR\x05tasks\"h\n" +
"\bDebugRes\x12 \n" +
"\vPrintOutput\x18\x01 \x01(\tR\vPrintOutput\x12\x14\n" +
"\x05Error\x18\x02 \x01(\tR\x05Error\x12$\n" +
"\rTargetsOutput\x18\x03 \x01(\tR\rTargetsOutput*\xea\x03\n" +
"\tErrorCode\x12\b\n" + "\tErrorCode\x12\b\n" +
"\x04SUCC\x10\x00\x12\x13\n" + "\x04SUCC\x10\x00\x12\x13\n" +
"\x0fINVALID_ACCOUNT\x10e\x12\x15\n" + "\x0fINVALID_ACCOUNT\x10e\x12\x15\n" +
@@ -1976,7 +2178,7 @@ func file_cmd_proto_rawDescGZIP() []byte {
} }
var file_cmd_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_cmd_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_cmd_proto_msgTypes = make([]protoimpl.MessageInfo, 22) var file_cmd_proto_msgTypes = make([]protoimpl.MessageInfo, 24)
var file_cmd_proto_goTypes = []any{ var file_cmd_proto_goTypes = []any{
(ErrorCode)(0), // 0: saasapi.ErrorCode (ErrorCode)(0), // 0: saasapi.ErrorCode
(CmdErrorCode)(0), // 1: saasapi.CmdErrorCode (CmdErrorCode)(0), // 1: saasapi.CmdErrorCode
@@ -1998,11 +2200,13 @@ var file_cmd_proto_goTypes = []any{
(*TaskInfo)(nil), // 17: saasapi.TaskInfo (*TaskInfo)(nil), // 17: saasapi.TaskInfo
(*FileInfo)(nil), // 18: saasapi.FileInfo (*FileInfo)(nil), // 18: saasapi.FileInfo
(*FileBlock)(nil), // 19: saasapi.FileBlock (*FileBlock)(nil), // 19: saasapi.FileBlock
(*SaasRes)(nil), // 20: saasapi.SaasRes (*Debug)(nil), // 20: saasapi.Debug
(*ReadRes)(nil), // 21: saasapi.ReadRes (*SaasRes)(nil), // 21: saasapi.SaasRes
(*WriteRes)(nil), // 22: saasapi.WriteRes (*ReadRes)(nil), // 22: saasapi.ReadRes
(*ValueItem)(nil), // 23: saasapi.ValueItem (*WriteRes)(nil), // 23: saasapi.WriteRes
(*TaskListRes)(nil), // 24: saasapi.TaskListRes (*ValueItem)(nil), // 24: saasapi.ValueItem
(*TaskListRes)(nil), // 25: saasapi.TaskListRes
(*DebugRes)(nil), // 26: saasapi.DebugRes
} }
var file_cmd_proto_depIdxs = []int32{ var file_cmd_proto_depIdxs = []int32{
4, // 0: saasapi.SaasReq.read:type_name -> saasapi.Read 4, // 0: saasapi.SaasReq.read:type_name -> saasapi.Read
@@ -2013,36 +2217,39 @@ var file_cmd_proto_depIdxs = []int32{
15, // 5: saasapi.SaasReq.task_run:type_name -> saasapi.TaskRun 15, // 5: saasapi.SaasReq.task_run:type_name -> saasapi.TaskRun
16, // 6: saasapi.SaasReq.task_delete:type_name -> saasapi.TaskDelete 16, // 6: saasapi.SaasReq.task_delete:type_name -> saasapi.TaskDelete
17, // 7: saasapi.SaasReq.task_info:type_name -> saasapi.TaskInfo 17, // 7: saasapi.SaasReq.task_info:type_name -> saasapi.TaskInfo
5, // 8: saasapi.Read.read_items:type_name -> saasapi.ReadItem 20, // 8: saasapi.SaasReq.debug:type_name -> saasapi.Debug
7, // 9: saasapi.Write.write_items:type_name -> saasapi.WriteItem 5, // 9: saasapi.Read.read_items:type_name -> saasapi.ReadItem
8, // 10: saasapi.WriteItem.write_bytes:type_name -> saasapi.Bytes 7, // 10: saasapi.Write.write_items:type_name -> saasapi.WriteItem
9, // 11: saasapi.WriteItem.write_uint32s:type_name -> saasapi.Uint32s 8, // 11: saasapi.WriteItem.write_bytes:type_name -> saasapi.Bytes
10, // 12: saasapi.WriteItem.write_flags_with_expire:type_name -> saasapi.FlagsWithExpire 9, // 12: saasapi.WriteItem.write_uint32s:type_name -> saasapi.Uint32s
11, // 13: saasapi.FlagsWithExpire.flags_with_expire:type_name -> saasapi.FlagWithExpire 10, // 13: saasapi.WriteItem.write_flags_with_expire:type_name -> saasapi.FlagsWithExpire
8, // 14: saasapi.ColumnWrite.write_bytes:type_name -> saasapi.Bytes 11, // 14: saasapi.FlagsWithExpire.flags_with_expire:type_name -> saasapi.FlagWithExpire
9, // 15: saasapi.ColumnWrite.write_uint32s:type_name -> saasapi.Uint32s 8, // 15: saasapi.ColumnWrite.write_bytes:type_name -> saasapi.Bytes
10, // 16: saasapi.ColumnWrite.write_flags_with_expire:type_name -> saasapi.FlagsWithExpire 9, // 16: saasapi.ColumnWrite.write_uint32s:type_name -> saasapi.Uint32s
18, // 17: saasapi.Task.task_file_infos:type_name -> saasapi.FileInfo 10, // 17: saasapi.ColumnWrite.write_flags_with_expire:type_name -> saasapi.FlagsWithExpire
2, // 18: saasapi.Task.status:type_name -> saasapi.TaskStatus 18, // 18: saasapi.Task.task_file_infos:type_name -> saasapi.FileInfo
2, // 19: saasapi.TaskList.status_filter:type_name -> saasapi.TaskStatus 2, // 19: saasapi.Task.status:type_name -> saasapi.TaskStatus
19, // 20: saasapi.FileInfo.file_blocks:type_name -> saasapi.FileBlock 2, // 20: saasapi.TaskList.status_filter:type_name -> saasapi.TaskStatus
0, // 21: saasapi.SaasRes.code:type_name -> saasapi.ErrorCode 19, // 21: saasapi.FileInfo.file_blocks:type_name -> saasapi.FileBlock
21, // 22: saasapi.SaasRes.read_res:type_name -> saasapi.ReadRes 7, // 22: saasapi.Debug.local_did_data:type_name -> saasapi.WriteItem
22, // 23: saasapi.SaasRes.write_res:type_name -> saasapi.WriteRes 7, // 23: saasapi.Debug.local_openid_data:type_name -> saasapi.WriteItem
13, // 24: saasapi.SaasRes.task_create_res:type_name -> saasapi.Task 0, // 24: saasapi.SaasRes.code:type_name -> saasapi.ErrorCode
24, // 25: saasapi.SaasRes.task_list_res:type_name -> saasapi.TaskListRes 22, // 25: saasapi.SaasRes.read_res:type_name -> saasapi.ReadRes
13, // 26: saasapi.SaasRes.task_run_res:type_name -> saasapi.Task 23, // 26: saasapi.SaasRes.write_res:type_name -> saasapi.WriteRes
13, // 27: saasapi.SaasRes.task_delete_res:type_name -> saasapi.Task 13, // 27: saasapi.SaasRes.task_create_res:type_name -> saasapi.Task
13, // 28: saasapi.SaasRes.task_info_res:type_name -> saasapi.Task 25, // 28: saasapi.SaasRes.task_list_res:type_name -> saasapi.TaskListRes
23, // 29: saasapi.ReadRes.cmd_res:type_name -> saasapi.ValueItem 13, // 29: saasapi.SaasRes.task_run_res:type_name -> saasapi.Task
1, // 30: saasapi.ValueItem.cmd_code:type_name -> saasapi.CmdErrorCode 13, // 30: saasapi.SaasRes.task_delete_res:type_name -> saasapi.Task
11, // 31: saasapi.ValueItem.flags_with_expire:type_name -> saasapi.FlagWithExpire 13, // 31: saasapi.SaasRes.task_info_res:type_name -> saasapi.Task
13, // 32: saasapi.TaskListRes.tasks:type_name -> saasapi.Task 24, // 32: saasapi.ReadRes.cmd_res:type_name -> saasapi.ValueItem
33, // [33:33] is the sub-list for method output_type 1, // 33: saasapi.ValueItem.cmd_code:type_name -> saasapi.CmdErrorCode
33, // [33:33] is the sub-list for method input_type 11, // 34: saasapi.ValueItem.flags_with_expire:type_name -> saasapi.FlagWithExpire
33, // [33:33] is the sub-list for extension type_name 13, // 35: saasapi.TaskListRes.tasks:type_name -> saasapi.Task
33, // [33:33] is the sub-list for extension extendee 36, // [36:36] is the sub-list for method output_type
0, // [0:33] is the sub-list for field type_name 36, // [36:36] is the sub-list for method input_type
36, // [36:36] is the sub-list for extension type_name
36, // [36:36] is the sub-list for extension extendee
0, // [0:36] is the sub-list for field type_name
} }
func init() { file_cmd_proto_init() } func init() { file_cmd_proto_init() }
@@ -2059,8 +2266,9 @@ func file_cmd_proto_init() {
(*SaasReq_TaskRun)(nil), (*SaasReq_TaskRun)(nil),
(*SaasReq_TaskDelete)(nil), (*SaasReq_TaskDelete)(nil),
(*SaasReq_TaskInfo)(nil), (*SaasReq_TaskInfo)(nil),
(*SaasReq_Debug)(nil),
} }
file_cmd_proto_msgTypes[17].OneofWrappers = []any{ file_cmd_proto_msgTypes[18].OneofWrappers = []any{
(*SaasRes_ReadRes)(nil), (*SaasRes_ReadRes)(nil),
(*SaasRes_WriteRes)(nil), (*SaasRes_WriteRes)(nil),
(*SaasRes_TaskCreateRes)(nil), (*SaasRes_TaskCreateRes)(nil),
@@ -2075,7 +2283,7 @@ func file_cmd_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_cmd_proto_rawDesc), len(file_cmd_proto_rawDesc)), RawDescriptor: unsafe.Slice(unsafe.StringData(file_cmd_proto_rawDesc), len(file_cmd_proto_rawDesc)),
NumEnums: 3, NumEnums: 3,
NumMessages: 22, NumMessages: 24,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@@ -16,6 +16,8 @@ message SaasReq {
TaskRun task_run = 22; // 执行任务 TaskRun task_run = 22; // 执行任务
TaskDelete task_delete = 23; // 删除任务 TaskDelete task_delete = 23; // 删除任务
TaskInfo task_info = 24; // 任务详情 TaskInfo task_info = 24; // 任务详情
Debug debug = 30; // 试运行lua脚本
} }
} }
@@ -90,6 +92,8 @@ message Task {
string task_description = 4; // 任务描述 string task_description = 4; // 任务描述
repeated FileInfo task_file_infos = 5; // 文件列表 repeated FileInfo task_file_infos = 5; // 文件列表
uint64 task_block_size = 6; // 文件块字节大小推荐200M uint64 task_block_size = 6; // 文件块字节大小推荐200M
string source_path = 7; // 任务数据源路径
uint64 task_size = 8; // 任务所有文件的总大小
// 以下字段只在返回时填写,用于提供服务端的任务状态。在请求时填写会被忽略 // 以下字段只在返回时填写,用于提供服务端的任务状态。在请求时填写会被忽略
string create_time = 10; // 创建时间 string create_time = 10; // 创建时间
@@ -131,6 +135,16 @@ message FileBlock {
bool uploaded = 3; // 是否已上传在TaskCreate/TaskInfo请求返回 bool uploaded = 3; // 是否已上传在TaskCreate/TaskInfo请求返回
} }
message Debug {
string lua_script = 1; // 要调试的lua脚本
bool use_server_data = 2; // 是否使用服务端用户数据
string server_did = 3; // 将从服务端读取该DID下的数据
string appid = 4; // 小程序/小游戏/公众号/视频号的appid
string server_openid = 5; // 将从服务端读取该openid下的数据需与appid配对使用
WriteItem local_did_data = 6; // 客户自定义DID用户数据
WriteItem local_openid_data = 7; // 客户定定义OpenID用户数据
}
// SaasRes 命令返回 // SaasRes 命令返回
message SaasRes { message SaasRes {
ErrorCode code = 1; // 返回码 ErrorCode code = 1; // 返回码
@@ -173,6 +187,12 @@ message TaskListRes {
repeated Task tasks = 1; // 任务列表 repeated Task tasks = 1; // 任务列表
} }
message DebugRes {
string PrintOutput = 1; // print输出
string Error = 2; // 错误信息
string TargetsOutput = 3; // 策略输出
}
// ErrorCode 返回码 // ErrorCode 返回码
enum ErrorCode { enum ErrorCode {
SUCC = 0; // 成功 SUCC = 0; // 成功

View File

@@ -1,4 +1,5 @@
debug/ debug/
saastool saastool
saastool_linux saastool_linux
cfg.toml *.toml
test/

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"os" "os"
"path" "path"
"path/filepath"
"runtime" "runtime"
"sort" "sort"
"strings" "strings"
@@ -89,6 +90,7 @@ func RunTaskMake(args ...string) error {
TaskDescription: *desc, TaskDescription: *desc,
Appid: *appid, Appid: *appid,
DataspaceId: *ds, DataspaceId: *ds,
SourcePath: *sourcePath,
}, },
} }
return doMakeHash(makeTaskParams, true) return doMakeHash(makeTaskParams, true)
@@ -207,10 +209,12 @@ func doTaskMake(makeTaskParams *makeTaskParams) error {
}) })
// 输出结果 // 输出结果
relPath, _ := filepath.Rel(makeTaskParams.task.GetSourcePath(), makeTaskParams.sourcePath)
fileInfo := &saasapi.FileInfo{ fileInfo := &saasapi.FileInfo{
FileName: makeTaskParams.sourcePath, FileName: relPath,
FileSize: uint64(fi.Size()), FileSize: uint64(fi.Size()),
} }
for _, r := range allResults { for _, r := range allResults {
fileInfo.FileBlocks = append(fileInfo.FileBlocks, &saasapi.FileBlock{ fileInfo.FileBlocks = append(fileInfo.FileBlocks, &saasapi.FileBlock{
BlockSha256: r.hash, BlockSha256: r.hash,
@@ -219,6 +223,8 @@ func doTaskMake(makeTaskParams *makeTaskParams) error {
} }
makeTaskParams.task.TaskFileInfos = append(makeTaskParams.task.TaskFileInfos, fileInfo) makeTaskParams.task.TaskFileInfos = append(makeTaskParams.task.TaskFileInfos, fileInfo)
makeTaskParams.task.TaskSize += uint64(fi.Size())
fmt.Println("") fmt.Println("")
return nil return nil
} }

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"os" "os"
"path/filepath"
"e.coding.net/rta/public/saasapi" "e.coding.net/rta/public/saasapi"
"e.coding.net/rta/public/saasapi/pkg/saashttp" "e.coding.net/rta/public/saasapi/pkg/saashttp"
@@ -58,10 +59,10 @@ func doTaskUpload(uploadTaskParams uploadTaskParams) error {
return err return err
} }
sourcePath := taskInfo.GetSourcePath()
totalFiles := len(taskInfo.GetTaskFileInfos()) totalFiles := len(taskInfo.GetTaskFileInfos())
fi := 0 fi := 0
for _, finfo := range taskInfo.GetTaskFileInfos() { for _, finfo := range taskInfo.GetTaskFileInfos() {
fi++ fi++
var f *os.File var f *os.File
offset := int64(0) offset := int64(0)
@@ -71,7 +72,11 @@ func doTaskUpload(uploadTaskParams uploadTaskParams) error {
bi++ bi++
if !binfo.GetUploaded() { if !binfo.GetUploaded() {
if f == nil { if f == nil {
f, err = os.Open(finfo.GetFileName()) fname := finfo.GetFileName()
if len(sourcePath) > 0 {
fname = filepath.Join(sourcePath, fname)
}
f, err = os.Open(fname)
if err != nil { if err != nil {
return err return err
} }