feat(service): add api proto. temp

This commit is contained in:
iyear 2024-02-12 20:44:06 +08:00
parent 150d93e783
commit 8d5ae22aa2
15 changed files with 1783 additions and 0 deletions

View File

@ -16,3 +16,6 @@ indent_style = tab
[*.md]
max_line_length = off
trim_trailing_whitespace = false
[*.proto]
indent_size = 2

View File

@ -0,0 +1,442 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc (unknown)
// source: task/v1/service.proto
package taskv1
import (
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type CreateTaskRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // task name for display
PartSize *int32 `protobuf:"varint,2,opt,name=part_size,json=partSize,proto3,oneof" json:"part_size,omitempty"` // part size in bytes
Threads *int32 `protobuf:"varint,3,opt,name=threads,proto3,oneof" json:"threads,omitempty"` // parallel num
Task *Task `protobuf:"bytes,4,opt,name=task,proto3" json:"task,omitempty"`
}
func (x *CreateTaskRequest) Reset() {
*x = CreateTaskRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_task_v1_service_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateTaskRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateTaskRequest) ProtoMessage() {}
func (x *CreateTaskRequest) ProtoReflect() protoreflect.Message {
mi := &file_task_v1_service_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateTaskRequest.ProtoReflect.Descriptor instead.
func (*CreateTaskRequest) Descriptor() ([]byte, []int) {
return file_task_v1_service_proto_rawDescGZIP(), []int{0}
}
func (x *CreateTaskRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *CreateTaskRequest) GetPartSize() int32 {
if x != nil && x.PartSize != nil {
return *x.PartSize
}
return 0
}
func (x *CreateTaskRequest) GetThreads() int32 {
if x != nil && x.Threads != nil {
return *x.Threads
}
return 0
}
func (x *CreateTaskRequest) GetTask() *Task {
if x != nil {
return x.Task
}
return nil
}
type CreateTaskResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Tid int32 `protobuf:"varint,1,opt,name=tid,proto3" json:"tid,omitempty"`
}
func (x *CreateTaskResponse) Reset() {
*x = CreateTaskResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_task_v1_service_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CreateTaskResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CreateTaskResponse) ProtoMessage() {}
func (x *CreateTaskResponse) ProtoReflect() protoreflect.Message {
mi := &file_task_v1_service_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use CreateTaskResponse.ProtoReflect.Descriptor instead.
func (*CreateTaskResponse) Descriptor() ([]byte, []int) {
return file_task_v1_service_proto_rawDescGZIP(), []int{1}
}
func (x *CreateTaskResponse) GetTid() int32 {
if x != nil {
return x.Tid
}
return 0
}
type ListTasksRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Offset int32 `protobuf:"varint,1,opt,name=offset,proto3" json:"offset,omitempty"` // tid cursor
Num int32 `protobuf:"varint,2,opt,name=num,proto3" json:"num,omitempty"` // num of tasks
Status TaskStatus `protobuf:"varint,3,opt,name=status,proto3,enum=task.v1.TaskStatus" json:"status,omitempty"` // task status
}
func (x *ListTasksRequest) Reset() {
*x = ListTasksRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_task_v1_service_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListTasksRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListTasksRequest) ProtoMessage() {}
func (x *ListTasksRequest) ProtoReflect() protoreflect.Message {
mi := &file_task_v1_service_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListTasksRequest.ProtoReflect.Descriptor instead.
func (*ListTasksRequest) Descriptor() ([]byte, []int) {
return file_task_v1_service_proto_rawDescGZIP(), []int{2}
}
func (x *ListTasksRequest) GetOffset() int32 {
if x != nil {
return x.Offset
}
return 0
}
func (x *ListTasksRequest) GetNum() int32 {
if x != nil {
return x.Num
}
return 0
}
func (x *ListTasksRequest) GetStatus() TaskStatus {
if x != nil {
return x.Status
}
return TaskStatus_UNSPECIFIED
}
type ListTasksResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Tasks []*Task `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"`
Total int32 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"`
}
func (x *ListTasksResponse) Reset() {
*x = ListTasksResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_task_v1_service_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListTasksResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListTasksResponse) ProtoMessage() {}
func (x *ListTasksResponse) ProtoReflect() protoreflect.Message {
mi := &file_task_v1_service_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListTasksResponse.ProtoReflect.Descriptor instead.
func (*ListTasksResponse) Descriptor() ([]byte, []int) {
return file_task_v1_service_proto_rawDescGZIP(), []int{3}
}
func (x *ListTasksResponse) GetTasks() []*Task {
if x != nil {
return x.Tasks
}
return nil
}
func (x *ListTasksResponse) GetTotal() int32 {
if x != nil {
return x.Total
}
return 0
}
var File_task_v1_service_proto protoreflect.FileDescriptor
var file_task_v1_service_proto_rawDesc = []byte{
0x0a, 0x15, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76, 0x31,
0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e,
0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61,
0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e,
0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12,
0x74, 0x61, 0x73, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x22, 0xa5, 0x01, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x73,
0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x09,
0x70, 0x61, 0x72, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48,
0x00, 0x52, 0x08, 0x70, 0x61, 0x72, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1d,
0x0a, 0x07, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x48,
0x01, 0x52, 0x07, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x73, 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a,
0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x74, 0x61,
0x73, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x04, 0x74, 0x61, 0x73, 0x6b,
0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x42, 0x0a,
0x0a, 0x08, 0x5f, 0x74, 0x68, 0x72, 0x65, 0x61, 0x64, 0x73, 0x22, 0x26, 0x0a, 0x12, 0x43, 0x72,
0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x10, 0x0a, 0x03, 0x74, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74,
0x69, 0x64, 0x22, 0x69, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74,
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x10,
0x0a, 0x03, 0x6e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6e, 0x75, 0x6d,
0x12, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e,
0x32, 0x13, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x4e, 0x0a,
0x11, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x23, 0x0a, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
0x0b, 0x32, 0x0d, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x73, 0x6b,
0x52, 0x05, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c,
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x32, 0xc1, 0x01,
0x0a, 0x0b, 0x54, 0x61, 0x73, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5b, 0x0a,
0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x1a, 0x2e, 0x74, 0x61,
0x73, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76,
0x31, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x3a, 0x01, 0x2a, 0x22,
0x09, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x55, 0x0a, 0x09, 0x4c, 0x69,
0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x12, 0x19, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76,
0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73,
0x74, 0x54, 0x61, 0x73, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11,
0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x12, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x73, 0x6b,
0x73, 0x42, 0xaa, 0x02, 0x92, 0x41, 0x9e, 0x01, 0x12, 0x75, 0x0a, 0x0f, 0x74, 0x64, 0x6c, 0x20,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x20, 0x41, 0x50, 0x49, 0x22, 0x23, 0x0a, 0x03, 0x74,
0x64, 0x6c, 0x12, 0x1c, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x79, 0x65, 0x61, 0x72, 0x2f, 0x74, 0x64, 0x6c,
0x2a, 0x38, 0x0a, 0x06, 0x41, 0x47, 0x50, 0x4c, 0x76, 0x33, 0x12, 0x2e, 0x68, 0x74, 0x74, 0x70,
0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69,
0x79, 0x65, 0x61, 0x72, 0x2f, 0x74, 0x64, 0x6c, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61,
0x69, 0x6e, 0x2f, 0x4c, 0x49, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x03, 0x31, 0x2e, 0x30, 0x72,
0x25, 0x0a, 0x08, 0x74, 0x64, 0x6c, 0x20, 0x64, 0x6f, 0x63, 0x73, 0x12, 0x19, 0x68, 0x74, 0x74,
0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x64, 0x6f, 0x63, 0x73, 0x2e, 0x69, 0x79, 0x65, 0x61, 0x72, 0x2e,
0x6d, 0x65, 0x2f, 0x74, 0x64, 0x6c, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x61, 0x73, 0x6b,
0x2e, 0x76, 0x31, 0x42, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x69, 0x79, 0x65, 0x61, 0x72, 0x2f, 0x74, 0x64, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65,
0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x76, 0x31, 0x3b, 0x74, 0x61, 0x73,
0x6b, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x07, 0x54, 0x61, 0x73, 0x6b,
0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x54, 0x61, 0x73, 0x6b, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13,
0x54, 0x61, 0x73, 0x6b, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x54, 0x61, 0x73, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_task_v1_service_proto_rawDescOnce sync.Once
file_task_v1_service_proto_rawDescData = file_task_v1_service_proto_rawDesc
)
func file_task_v1_service_proto_rawDescGZIP() []byte {
file_task_v1_service_proto_rawDescOnce.Do(func() {
file_task_v1_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_task_v1_service_proto_rawDescData)
})
return file_task_v1_service_proto_rawDescData
}
var file_task_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_task_v1_service_proto_goTypes = []interface{}{
(*CreateTaskRequest)(nil), // 0: task.v1.CreateTaskRequest
(*CreateTaskResponse)(nil), // 1: task.v1.CreateTaskResponse
(*ListTasksRequest)(nil), // 2: task.v1.ListTasksRequest
(*ListTasksResponse)(nil), // 3: task.v1.ListTasksResponse
(*Task)(nil), // 4: task.v1.Task
(TaskStatus)(0), // 5: task.v1.TaskStatus
}
var file_task_v1_service_proto_depIdxs = []int32{
4, // 0: task.v1.CreateTaskRequest.task:type_name -> task.v1.Task
5, // 1: task.v1.ListTasksRequest.status:type_name -> task.v1.TaskStatus
4, // 2: task.v1.ListTasksResponse.tasks:type_name -> task.v1.Task
0, // 3: task.v1.TaskService.CreateTask:input_type -> task.v1.CreateTaskRequest
2, // 4: task.v1.TaskService.ListTasks:input_type -> task.v1.ListTasksRequest
1, // 5: task.v1.TaskService.CreateTask:output_type -> task.v1.CreateTaskResponse
3, // 6: task.v1.TaskService.ListTasks:output_type -> task.v1.ListTasksResponse
5, // [5:7] is the sub-list for method output_type
3, // [3:5] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_task_v1_service_proto_init() }
func file_task_v1_service_proto_init() {
if File_task_v1_service_proto != nil {
return
}
file_task_v1_task_proto_init()
if !protoimpl.UnsafeEnabled {
file_task_v1_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateTaskRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_task_v1_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CreateTaskResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_task_v1_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListTasksRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_task_v1_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListTasksResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_task_v1_service_proto_msgTypes[0].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_task_v1_service_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_task_v1_service_proto_goTypes,
DependencyIndexes: file_task_v1_service_proto_depIdxs,
MessageInfos: file_task_v1_service_proto_msgTypes,
}.Build()
File_task_v1_service_proto = out.File
file_task_v1_service_proto_rawDesc = nil
file_task_v1_service_proto_goTypes = nil
file_task_v1_service_proto_depIdxs = nil
}

View File

@ -0,0 +1,250 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: task/v1/service.proto
/*
Package taskv1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package taskv1
import (
"context"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join
func request_TaskService_CreateTask_0(ctx context.Context, marshaler runtime.Marshaler, client TaskServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateTaskRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CreateTask(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_TaskService_CreateTask_0(ctx context.Context, marshaler runtime.Marshaler, server TaskServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateTaskRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.CreateTask(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_TaskService_ListTasks_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_TaskService_ListTasks_0(ctx context.Context, marshaler runtime.Marshaler, client TaskServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListTasksRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TaskService_ListTasks_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ListTasks(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_TaskService_ListTasks_0(ctx context.Context, marshaler runtime.Marshaler, server TaskServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListTasksRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TaskService_ListTasks_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.ListTasks(ctx, &protoReq)
return msg, metadata, err
}
// RegisterTaskServiceHandlerServer registers the http handlers for service TaskService to "mux".
// UnaryRPC :call TaskServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTaskServiceHandlerFromEndpoint instead.
func RegisterTaskServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TaskServiceServer) error {
mux.Handle("POST", pattern_TaskService_CreateTask_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/task.v1.TaskService/CreateTask", runtime.WithHTTPPathPattern("/v1/tasks"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_TaskService_CreateTask_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_TaskService_CreateTask_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_TaskService_ListTasks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/task.v1.TaskService/ListTasks", runtime.WithHTTPPathPattern("/v1/tasks"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_TaskService_ListTasks_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_TaskService_ListTasks_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterTaskServiceHandlerFromEndpoint is same as RegisterTaskServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterTaskServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.DialContext(ctx, endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterTaskServiceHandler(ctx, mux, conn)
}
// RegisterTaskServiceHandler registers the http handlers for service TaskService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterTaskServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterTaskServiceHandlerClient(ctx, mux, NewTaskServiceClient(conn))
}
// RegisterTaskServiceHandlerClient registers the http handlers for service TaskService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TaskServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TaskServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "TaskServiceClient" to call the correct interceptors.
func RegisterTaskServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TaskServiceClient) error {
mux.Handle("POST", pattern_TaskService_CreateTask_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/task.v1.TaskService/CreateTask", runtime.WithHTTPPathPattern("/v1/tasks"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_TaskService_CreateTask_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_TaskService_CreateTask_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_TaskService_ListTasks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/task.v1.TaskService/ListTasks", runtime.WithHTTPPathPattern("/v1/tasks"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_TaskService_ListTasks_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_TaskService_ListTasks_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_TaskService_CreateTask_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "tasks"}, ""))
pattern_TaskService_ListTasks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "tasks"}, ""))
)
var (
forward_TaskService_CreateTask_0 = runtime.ForwardResponseMessage
forward_TaskService_ListTasks_0 = runtime.ForwardResponseMessage
)

View File

@ -0,0 +1,146 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc (unknown)
// source: task/v1/service.proto
package taskv1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
TaskService_CreateTask_FullMethodName = "/task.v1.TaskService/CreateTask"
TaskService_ListTasks_FullMethodName = "/task.v1.TaskService/ListTasks"
)
// TaskServiceClient is the client API for TaskService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type TaskServiceClient interface {
CreateTask(ctx context.Context, in *CreateTaskRequest, opts ...grpc.CallOption) (*CreateTaskResponse, error)
ListTasks(ctx context.Context, in *ListTasksRequest, opts ...grpc.CallOption) (*ListTasksResponse, error)
}
type taskServiceClient struct {
cc grpc.ClientConnInterface
}
func NewTaskServiceClient(cc grpc.ClientConnInterface) TaskServiceClient {
return &taskServiceClient{cc}
}
func (c *taskServiceClient) CreateTask(ctx context.Context, in *CreateTaskRequest, opts ...grpc.CallOption) (*CreateTaskResponse, error) {
out := new(CreateTaskResponse)
err := c.cc.Invoke(ctx, TaskService_CreateTask_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *taskServiceClient) ListTasks(ctx context.Context, in *ListTasksRequest, opts ...grpc.CallOption) (*ListTasksResponse, error) {
out := new(ListTasksResponse)
err := c.cc.Invoke(ctx, TaskService_ListTasks_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TaskServiceServer is the server API for TaskService service.
// All implementations must embed UnimplementedTaskServiceServer
// for forward compatibility
type TaskServiceServer interface {
CreateTask(context.Context, *CreateTaskRequest) (*CreateTaskResponse, error)
ListTasks(context.Context, *ListTasksRequest) (*ListTasksResponse, error)
mustEmbedUnimplementedTaskServiceServer()
}
// UnimplementedTaskServiceServer must be embedded to have forward compatible implementations.
type UnimplementedTaskServiceServer struct {
}
func (UnimplementedTaskServiceServer) CreateTask(context.Context, *CreateTaskRequest) (*CreateTaskResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateTask not implemented")
}
func (UnimplementedTaskServiceServer) ListTasks(context.Context, *ListTasksRequest) (*ListTasksResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListTasks not implemented")
}
func (UnimplementedTaskServiceServer) mustEmbedUnimplementedTaskServiceServer() {}
// UnsafeTaskServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TaskServiceServer will
// result in compilation errors.
type UnsafeTaskServiceServer interface {
mustEmbedUnimplementedTaskServiceServer()
}
func RegisterTaskServiceServer(s grpc.ServiceRegistrar, srv TaskServiceServer) {
s.RegisterService(&TaskService_ServiceDesc, srv)
}
func _TaskService_CreateTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateTaskRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TaskServiceServer).CreateTask(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: TaskService_CreateTask_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TaskServiceServer).CreateTask(ctx, req.(*CreateTaskRequest))
}
return interceptor(ctx, in, info, handler)
}
func _TaskService_ListTasks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListTasksRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TaskServiceServer).ListTasks(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: TaskService_ListTasks_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TaskServiceServer).ListTasks(ctx, req.(*ListTasksRequest))
}
return interceptor(ctx, in, info, handler)
}
// TaskService_ServiceDesc is the grpc.ServiceDesc for TaskService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var TaskService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "task.v1.TaskService",
HandlerType: (*TaskServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateTask",
Handler: _TaskService_CreateTask_Handler,
},
{
MethodName: "ListTasks",
Handler: _TaskService_ListTasks_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "task/v1/service.proto",
}

View File

@ -0,0 +1,436 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc (unknown)
// source: task/v1/task.proto
package taskv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type TaskStatus int32
const (
TaskStatus_UNSPECIFIED TaskStatus = 0
TaskStatus_ACTIVE TaskStatus = 1
TaskStatus_WAITING TaskStatus = 2
TaskStatus_STOPPED TaskStatus = 3
)
// Enum value maps for TaskStatus.
var (
TaskStatus_name = map[int32]string{
0: "UNSPECIFIED",
1: "ACTIVE",
2: "WAITING",
3: "STOPPED",
}
TaskStatus_value = map[string]int32{
"UNSPECIFIED": 0,
"ACTIVE": 1,
"WAITING": 2,
"STOPPED": 3,
}
)
func (x TaskStatus) Enum() *TaskStatus {
p := new(TaskStatus)
*p = x
return p
}
func (x TaskStatus) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (TaskStatus) Descriptor() protoreflect.EnumDescriptor {
return file_task_v1_task_proto_enumTypes[0].Descriptor()
}
func (TaskStatus) Type() protoreflect.EnumType {
return &file_task_v1_task_proto_enumTypes[0]
}
func (x TaskStatus) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use TaskStatus.Descriptor instead.
func (TaskStatus) EnumDescriptor() ([]byte, []int) {
return file_task_v1_task_proto_rawDescGZIP(), []int{0}
}
// you should only pass one of the following fields: download, upload
type Task struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// Types that are assignable to Task:
//
// *Task_Download
// *Task_Upload
Task isTask_Task `protobuf_oneof:"task"`
}
func (x *Task) Reset() {
*x = Task{}
if protoimpl.UnsafeEnabled {
mi := &file_task_v1_task_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Task) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Task) ProtoMessage() {}
func (x *Task) ProtoReflect() protoreflect.Message {
mi := &file_task_v1_task_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Task.ProtoReflect.Descriptor instead.
func (*Task) Descriptor() ([]byte, []int) {
return file_task_v1_task_proto_rawDescGZIP(), []int{0}
}
func (x *Task) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (m *Task) GetTask() isTask_Task {
if m != nil {
return m.Task
}
return nil
}
func (x *Task) GetDownload() *DownloadTask {
if x, ok := x.GetTask().(*Task_Download); ok {
return x.Download
}
return nil
}
func (x *Task) GetUpload() *UploadTask {
if x, ok := x.GetTask().(*Task_Upload); ok {
return x.Upload
}
return nil
}
type isTask_Task interface {
isTask_Task()
}
type Task_Download struct {
Download *DownloadTask `protobuf:"bytes,2,opt,name=download,proto3,oneof"` // download task
}
type Task_Upload struct {
Upload *UploadTask `protobuf:"bytes,3,opt,name=upload,proto3,oneof"` // upload task
}
func (*Task_Download) isTask_Task() {}
func (*Task_Upload) isTask_Task() {}
type DownloadTask struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// Available chat formats:
// - @iyear
// - iyear
// - 123456789 (ID)
// - https://t.me/iyear
// - +1 123456789 (Phone)
Chat string `protobuf:"bytes,1,opt,name=chat,proto3" json:"chat,omitempty"`
// message id
Msg int32 `protobuf:"varint,2,opt,name=msg,proto3" json:"msg,omitempty"`
// download dir
Dir string `protobuf:"bytes,3,opt,name=dir,proto3" json:"dir,omitempty"`
// download file name template
Out string `protobuf:"bytes,4,opt,name=out,proto3" json:"out,omitempty"`
// skip file with the same name(without extension) and size
SkipSame bool `protobuf:"varint,5,opt,name=skip_same,json=skipSame,proto3" json:"skip_same,omitempty"`
// rewrite file extension according to file header MIME
RewriteExt bool `protobuf:"varint,6,opt,name=rewrite_ext,json=rewriteExt,proto3" json:"rewrite_ext,omitempty"`
}
func (x *DownloadTask) Reset() {
*x = DownloadTask{}
if protoimpl.UnsafeEnabled {
mi := &file_task_v1_task_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DownloadTask) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DownloadTask) ProtoMessage() {}
func (x *DownloadTask) ProtoReflect() protoreflect.Message {
mi := &file_task_v1_task_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DownloadTask.ProtoReflect.Descriptor instead.
func (*DownloadTask) Descriptor() ([]byte, []int) {
return file_task_v1_task_proto_rawDescGZIP(), []int{1}
}
func (x *DownloadTask) GetChat() string {
if x != nil {
return x.Chat
}
return ""
}
func (x *DownloadTask) GetMsg() int32 {
if x != nil {
return x.Msg
}
return 0
}
func (x *DownloadTask) GetDir() string {
if x != nil {
return x.Dir
}
return ""
}
func (x *DownloadTask) GetOut() string {
if x != nil {
return x.Out
}
return ""
}
func (x *DownloadTask) GetSkipSame() bool {
if x != nil {
return x.SkipSame
}
return false
}
func (x *DownloadTask) GetRewriteExt() bool {
if x != nil {
return x.RewriteExt
}
return false
}
type UploadTask struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *UploadTask) Reset() {
*x = UploadTask{}
if protoimpl.UnsafeEnabled {
mi := &file_task_v1_task_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UploadTask) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UploadTask) ProtoMessage() {}
func (x *UploadTask) ProtoReflect() protoreflect.Message {
mi := &file_task_v1_task_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UploadTask.ProtoReflect.Descriptor instead.
func (*UploadTask) Descriptor() ([]byte, []int) {
return file_task_v1_task_proto_rawDescGZIP(), []int{2}
}
var File_task_v1_task_proto protoreflect.FileDescriptor
var file_task_v1_task_proto_rawDesc = []byte{
0x0a, 0x12, 0x74, 0x61, 0x73, 0x6b, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76, 0x31, 0x22, 0x82, 0x01,
0x0a, 0x04, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x33, 0x0a, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f,
0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e,
0x76, 0x31, 0x2e, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x48,
0x00, 0x52, 0x08, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x2d, 0x0a, 0x06, 0x75,
0x70, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x61,
0x73, 0x6b, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b,
0x48, 0x00, 0x52, 0x06, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x61,
0x73, 0x6b, 0x22, 0x96, 0x01, 0x0a, 0x0c, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x54,
0x61, 0x73, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x68, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x63, 0x68, 0x61, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02,
0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x69, 0x72,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6f,
0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x75, 0x74, 0x12, 0x1b, 0x0a,
0x09, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x73, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08,
0x52, 0x08, 0x73, 0x6b, 0x69, 0x70, 0x53, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65,
0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x65, 0x78, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52,
0x0a, 0x72, 0x65, 0x77, 0x72, 0x69, 0x74, 0x65, 0x45, 0x78, 0x74, 0x22, 0x0c, 0x0a, 0x0a, 0x55,
0x70, 0x6c, 0x6f, 0x61, 0x64, 0x54, 0x61, 0x73, 0x6b, 0x2a, 0x43, 0x0a, 0x0a, 0x54, 0x61, 0x73,
0x6b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45,
0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x43, 0x54, 0x49,
0x56, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x57, 0x41, 0x49, 0x54, 0x49, 0x4e, 0x47, 0x10,
0x02, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x54, 0x4f, 0x50, 0x50, 0x45, 0x44, 0x10, 0x03, 0x42, 0x85,
0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x2e, 0x76, 0x31, 0x42, 0x09,
0x54, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x79, 0x65, 0x61, 0x72, 0x2f, 0x74, 0x64,
0x6c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x74, 0x61, 0x73,
0x6b, 0x2f, 0x76, 0x31, 0x3b, 0x74, 0x61, 0x73, 0x6b, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x54, 0x58,
0x58, 0xaa, 0x02, 0x07, 0x54, 0x61, 0x73, 0x6b, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x54, 0x61,
0x73, 0x6b, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x13, 0x54, 0x61, 0x73, 0x6b, 0x5c, 0x56, 0x31, 0x5c,
0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x54, 0x61,
0x73, 0x6b, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_task_v1_task_proto_rawDescOnce sync.Once
file_task_v1_task_proto_rawDescData = file_task_v1_task_proto_rawDesc
)
func file_task_v1_task_proto_rawDescGZIP() []byte {
file_task_v1_task_proto_rawDescOnce.Do(func() {
file_task_v1_task_proto_rawDescData = protoimpl.X.CompressGZIP(file_task_v1_task_proto_rawDescData)
})
return file_task_v1_task_proto_rawDescData
}
var file_task_v1_task_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_task_v1_task_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_task_v1_task_proto_goTypes = []interface{}{
(TaskStatus)(0), // 0: task.v1.TaskStatus
(*Task)(nil), // 1: task.v1.Task
(*DownloadTask)(nil), // 2: task.v1.DownloadTask
(*UploadTask)(nil), // 3: task.v1.UploadTask
}
var file_task_v1_task_proto_depIdxs = []int32{
2, // 0: task.v1.Task.download:type_name -> task.v1.DownloadTask
3, // 1: task.v1.Task.upload:type_name -> task.v1.UploadTask
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_task_v1_task_proto_init() }
func file_task_v1_task_proto_init() {
if File_task_v1_task_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_task_v1_task_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Task); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_task_v1_task_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DownloadTask); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_task_v1_task_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UploadTask); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_task_v1_task_proto_msgTypes[0].OneofWrappers = []interface{}{
(*Task_Download)(nil),
(*Task_Upload)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_task_v1_task_proto_rawDesc,
NumEnums: 1,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_task_v1_task_proto_goTypes,
DependencyIndexes: file_task_v1_task_proto_depIdxs,
EnumInfos: file_task_v1_task_proto_enumTypes,
MessageInfos: file_task_v1_task_proto_msgTypes,
}.Build()
File_task_v1_task_proto = out.File
file_task_v1_task_proto_rawDesc = nil
file_task_v1_task_proto_goTypes = nil
file_task_v1_task_proto_depIdxs = nil
}

View File

@ -0,0 +1,254 @@
{
"swagger": "2.0",
"info": {
"title": "tdl Service API",
"version": "1.0",
"contact": {
"name": "tdl",
"url": "https://github.com/iyear/tdl"
},
"license": {
"name": "AGPLv3",
"url": "https://github.com/iyear/tdl/blob/main/LICENSE"
}
},
"tags": [
{
"name": "TaskService"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/v1/tasks": {
"get": {
"operationId": "TaskService_ListTasks",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1ListTasksResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "offset",
"description": "tid cursor",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
},
{
"name": "num",
"description": "num of tasks",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
},
{
"name": "status",
"description": "task status",
"in": "query",
"required": false,
"type": "string",
"enum": [
"UNSPECIFIED",
"ACTIVE",
"WAITING",
"STOPPED"
],
"default": "UNSPECIFIED"
}
],
"tags": [
"TaskService"
]
},
"post": {
"operationId": "TaskService_CreateTask",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1CreateTaskResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1CreateTaskRequest"
}
}
],
"tags": [
"TaskService"
]
}
}
},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
},
"v1CreateTaskRequest": {
"type": "object",
"properties": {
"name": {
"type": "string",
"title": "task name for display"
},
"partSize": {
"type": "integer",
"format": "int32",
"title": "part size in bytes"
},
"threads": {
"type": "integer",
"format": "int32",
"title": "parallel num"
},
"task": {
"$ref": "#/definitions/v1Task"
}
}
},
"v1CreateTaskResponse": {
"type": "object",
"properties": {
"tid": {
"type": "integer",
"format": "int32"
}
}
},
"v1DownloadTask": {
"type": "object",
"properties": {
"chat": {
"type": "string",
"title": "Available chat formats:\n - @iyear\n - iyear\n - 123456789 (ID)\n - https://t.me/iyear\n - +1 123456789 (Phone)"
},
"msg": {
"type": "integer",
"format": "int32",
"title": "message id"
},
"dir": {
"type": "string",
"title": "download dir"
},
"out": {
"type": "string",
"title": "download file name template"
},
"skipSame": {
"type": "boolean",
"title": "skip file with the same name(without extension) and size"
},
"rewriteExt": {
"type": "boolean",
"title": "rewrite file extension according to file header MIME"
}
}
},
"v1ListTasksResponse": {
"type": "object",
"properties": {
"tasks": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1Task"
}
},
"total": {
"type": "integer",
"format": "int32"
}
}
},
"v1Task": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "int64"
},
"download": {
"$ref": "#/definitions/v1DownloadTask",
"title": "download task"
},
"upload": {
"$ref": "#/definitions/v1UploadTask",
"title": "upload task"
}
},
"title": "you should only pass one of the following fields: download, upload"
},
"v1TaskStatus": {
"type": "string",
"enum": [
"UNSPECIFIED",
"ACTIVE",
"WAITING",
"STOPPED"
],
"default": "UNSPECIFIED"
},
"v1UploadTask": {
"type": "object"
}
},
"externalDocs": {
"description": "tdl docs",
"url": "https://docs.iyear.me/tdl"
}
}

View File

@ -0,0 +1,44 @@
{
"swagger": "2.0",
"info": {
"title": "task/v1/task.proto",
"version": "version not set"
},
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {},
"definitions": {
"protobufAny": {
"type": "object",
"properties": {
"@type": {
"type": "string"
}
},
"additionalProperties": {}
},
"rpcStatus": {
"type": "object",
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
},
"details": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/protobufAny"
}
}
}
}
}
}

19
api/go.mod Normal file
View File

@ -0,0 +1,19 @@
module github.com/iyear/tdl/api
go 1.19
require (
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
)
require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect
)

26
api/go.sum Normal file
View File

@ -0,0 +1,26 @@
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 h1:YJ5pD9rF8o9Qtta0Cmy9rdBwkSjrTCT6XTiUQVOtIos=
google.golang.org/genproto v0.0.0-20231212172506-995d672761c0/go.mod h1:l/k7rMz0vFTBPy+tFSGvXEd3z+BcoG1k7EHbqm+YBsY=
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM=
google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU=
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=

13
api/proto/buf.lock Normal file
View File

@ -0,0 +1,13 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: a86849a25cc04f4dbe9b15ddddfbc488
digest: shake256:e19143328f8cbfe13fc226aeee5e63773ca494693a72740a7560664270039a380d94a1344234b88c7691311460df9a9b1c2982190d0a2612eae80368718e1943
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: 3f42134f4c564983838425bc43c7a65f
digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92

10
api/proto/buf.yaml Normal file
View File

@ -0,0 +1,10 @@
version: v1
deps:
- buf.build/googleapis/googleapis:a86849a25cc04f4dbe9b15ddddfbc488
- buf.build/grpc-ecosystem/grpc-gateway:3f42134f4c564983838425bc43c7a65f
breaking:
use:
- FILE
lint:
use:
- DEFAULT

View File

@ -0,0 +1,64 @@
syntax = "proto3";
package task.v1;
import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "task/v1/task.proto";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "tdl Service API";
version: "1.0";
contact: {
name: "tdl";
url: "https://github.com/iyear/tdl";
};
license: {
name: "AGPLv3";
url: "https://github.com/iyear/tdl/blob/main/LICENSE";
};
};
external_docs: {
description: "tdl docs";
url: "https://docs.iyear.me/tdl";
};
};
service TaskService {
rpc CreateTask (CreateTaskRequest) returns (CreateTaskResponse) {
option (google.api.http) = {
post: "/v1/tasks"
body: "*"
};
}
rpc ListTasks (ListTasksRequest) returns (ListTasksResponse) {
option (google.api.http) = {
get: "/v1/tasks"
};
}
}
message CreateTaskRequest {
string name = 1; // task name for display
optional int32 part_size = 2; // part size in bytes
optional int32 threads = 3; // parallel num
Task task = 4;
}
message CreateTaskResponse {
int32 id = 1;
}
message ListTasksRequest {
int32 offset = 1; // tid cursor
int32 num = 2; // num of tasks
TaskStatus status = 3; // task status
}
message ListTasksResponse {
repeated Task tasks = 1;
int32 total = 2;
}

View File

@ -0,0 +1,50 @@
syntax = "proto3";
package task.v1;
enum TaskStatus {
TASK_STATUS_UNSPECIFIED = 0;
TASK_STATUS_ACTIVE = 1;
TASK_STATUS_WAITING = 2;
TASK_STATUS_STOPPED = 3;
}
// you should only pass one of the following fields: download, upload
message Task {
int64 id = 1;
oneof task {
DownloadTask download = 2; // download task
UploadTask upload = 3; // upload task
}
}
message DownloadTask {
// Available chat formats:
// - @iyear
// - iyear
// - 123456789 (ID)
// - https://t.me/iyear
// - +1 123456789 (Phone)
string chat = 1;
// message id
int32 msg = 2;
// download dir
string dir = 3;
// download file name template
string out = 4;
// skip file with the same name(without extension) and size
bool skip_same = 5;
// rewrite file extension according to file header MIME
bool rewrite_ext = 6;
}
message UploadTask {
}

23
buf.gen.yaml Normal file
View File

@ -0,0 +1,23 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: "github.com/iyear/tdl/api/gen/go"
except:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
plugins:
- plugin: buf.build/protocolbuffers/go:v1.32.0
out: api/gen/go
opt:
- paths=source_relative
- plugin: buf.build/grpc/go
out: api/gen/go
opt:
- paths=source_relative
- plugin: buf.build/grpc-ecosystem/gateway:v2.19.0
out: api/gen/go
opt:
- paths=source_relative
- plugin: buf.build/grpc-ecosystem/openapiv2:v2.19.0
out: api/gen/openapi

3
buf.work.yaml Normal file
View File

@ -0,0 +1,3 @@
version: v1
directories:
- api/proto