Versions in this module Expand all Collapse all v0 v0.2.0 Apr 14, 2021 Changes in this version + var File_job_proto protoreflect.FileDescriptor + var File_staff_proto protoreflect.FileDescriptor + var File_task_proto protoreflect.FileDescriptor + var File_worker_proto protoreflect.FileDescriptor + var JobDone = errors.New("job done") + var JobPrefix = []byte + var JobStatus_name = map[int32]string + var JobStatus_value = map[string]int32 + var JobType_name = map[int32]string + var JobType_value = map[string]int32 + var PollJobStatus_name = map[int32]string + var PollJobStatus_value = map[string]int32 + var PollStatus_name = map[int32]string + var PollStatus_value = map[string]int32 + var StaffPrefix = []byte + var Staff_ServiceDesc = grpc.ServiceDesc + var StorageType_name = map[int32]string + var StorageType_value = map[string]int32 + var TaskDone = errors.New("task done") + var TaskPrefix = []byte + var TaskStatus_name = map[int32]string + var TaskStatus_value = map[string]int32 + var TaskType_name = map[int32]string + var TaskType_value = map[string]int32 + var Worker_ServiceDesc = grpc.ServiceDesc + func FormatPair(p *Pair) types.Pair + func FormatStorage(st *Storage) (types.Storager, error) + func JobKey(jobId string) []byte + func RegisterStaffServer(s grpc.ServiceRegistrar, srv StaffServer) + func RegisterWorkerServer(s grpc.ServiceRegistrar, srv WorkerServer) + func StaffKey(staffId string) []byte + func StaffTaskKey(staffId, taskId string) []byte + func StaffTaskPrefix(staffId string) []byte + func TaskKey(taskId string) []byte + func TaskLeaderKey(taskId string) []byte + type CopyDirJob struct + Dst uint32 + DstPath string + Recursive bool + Src uint32 + SrcPath string + func (*CopyDirJob) Descriptor() ([]byte, []int) + func (*CopyDirJob) ProtoMessage() + func (x *CopyDirJob) GetDst() uint32 + func (x *CopyDirJob) GetDstPath() string + func (x *CopyDirJob) GetRecursive() bool + func (x *CopyDirJob) GetSrc() uint32 + func (x *CopyDirJob) GetSrcPath() string + func (x *CopyDirJob) ProtoReflect() protoreflect.Message + func (x *CopyDirJob) Reset() + func (x *CopyDirJob) String() string + type CopyFileJob struct + Dst uint32 + DstPath string + Src uint32 + SrcPath string + func (*CopyFileJob) Descriptor() ([]byte, []int) + func (*CopyFileJob) ProtoMessage() + func (x *CopyFileJob) GetDst() uint32 + func (x *CopyFileJob) GetDstPath() string + func (x *CopyFileJob) GetSrc() uint32 + func (x *CopyFileJob) GetSrcPath() string + func (x *CopyFileJob) ProtoReflect() protoreflect.Message + func (x *CopyFileJob) Reset() + func (x *CopyFileJob) String() string + type CopyMultipartFileJob struct + Dst uint32 + DstPath string + Size int64 + Src uint32 + SrcPath string + func (*CopyMultipartFileJob) Descriptor() ([]byte, []int) + func (*CopyMultipartFileJob) ProtoMessage() + func (x *CopyMultipartFileJob) GetDst() uint32 + func (x *CopyMultipartFileJob) GetDstPath() string + func (x *CopyMultipartFileJob) GetSize() int64 + func (x *CopyMultipartFileJob) GetSrc() uint32 + func (x *CopyMultipartFileJob) GetSrcPath() string + func (x *CopyMultipartFileJob) ProtoReflect() protoreflect.Message + func (x *CopyMultipartFileJob) Reset() + func (x *CopyMultipartFileJob) String() string + type CopyMultipartJob struct + Dst uint32 + DstPath string + Index uint32 + MultipartId string + Offset int64 + Size int64 + Src uint32 + SrcPath string + func (*CopyMultipartJob) Descriptor() ([]byte, []int) + func (*CopyMultipartJob) ProtoMessage() + func (x *CopyMultipartJob) GetDst() uint32 + func (x *CopyMultipartJob) GetDstPath() string + func (x *CopyMultipartJob) GetIndex() uint32 + func (x *CopyMultipartJob) GetMultipartId() string + func (x *CopyMultipartJob) GetOffset() int64 + func (x *CopyMultipartJob) GetSize() int64 + func (x *CopyMultipartJob) GetSrc() uint32 + func (x *CopyMultipartJob) GetSrcPath() string + func (x *CopyMultipartJob) ProtoReflect() protoreflect.Message + func (x *CopyMultipartJob) Reset() + func (x *CopyMultipartJob) String() string + type CopySingleFileJob struct + Dst uint32 + DstPath string + Size int64 + Src uint32 + SrcPath string + func (*CopySingleFileJob) Descriptor() ([]byte, []int) + func (*CopySingleFileJob) ProtoMessage() + func (x *CopySingleFileJob) GetDst() uint32 + func (x *CopySingleFileJob) GetDstPath() string + func (x *CopySingleFileJob) GetSize() int64 + func (x *CopySingleFileJob) GetSrc() uint32 + func (x *CopySingleFileJob) GetSrcPath() string + func (x *CopySingleFileJob) ProtoReflect() protoreflect.Message + func (x *CopySingleFileJob) Reset() + func (x *CopySingleFileJob) String() string + type CreateJobReply struct + Status uint32 + func (*CreateJobReply) Descriptor() ([]byte, []int) + func (*CreateJobReply) ProtoMessage() + func (x *CreateJobReply) GetStatus() uint32 + func (x *CreateJobReply) ProtoReflect() protoreflect.Message + func (x *CreateJobReply) Reset() + func (x *CreateJobReply) String() string + type CreateJobRequest struct + Job *Job + StaffId string + func (*CreateJobRequest) Descriptor() ([]byte, []int) + func (*CreateJobRequest) ProtoMessage() + func (x *CreateJobRequest) GetJob() *Job + func (x *CreateJobRequest) GetStaffId() string + func (x *CreateJobRequest) ProtoReflect() protoreflect.Message + func (x *CreateJobRequest) Reset() + func (x *CreateJobRequest) String() string type DB + func (d *DB) Close() (err error) + func (d *DB) CloseTxn(txn *badger.Txn, err error) error + func (d *DB) CreateStaff(id string) (s *Staff, err error) + func (d *DB) DeleteJob(ctx context.Context, jobId string) (err error) + func (d *DB) DeleteStaffTask(txn *badger.Txn, staffId, taskId string) (err error) + func (d *DB) ElectTaskLeader(taskId, staffId, staffAddr string) (electedStaffId, electedStaffAddr string, err error) + func (d *DB) GetJob(ctx context.Context, jobId string) (j *Job, err error) + func (d *DB) GetStaff(id string) (s *Staff, err error) + func (d *DB) InsertJob(j *Job) error + func (d *DB) InsertStaffTask(txn *badger.Txn, staffId, taskId string) (err error) + func (d *DB) InsertTask(txn *badger.Txn, t *Task) (err error) + func (d *DB) ListJobs() + func (d *DB) ListStaffTasks(txn *badger.Txn, staffId string) (taskIds []string, err error) + func (d *DB) ListStaffs() ([]*Staff, error) + func (d *DB) NextStaffTask(txn *badger.Txn, staffId string) (taskId string, err error) + func (d *DB) SubscribeJob(ctx context.Context, fn func(j *Job)) (err error) + func (d *DB) SubscribeTask(ctx context.Context, fn func(t *Task)) (err error) + func (d *DB) UpdateTask(t *Task) error + func (d *DB) WaitJob(ctx context.Context, jobId string) (err error) + func (d *DB) WaitTask(ctx context.Context, taskId string) (err error) + type ElectReply struct + LeaderAddr string + LeaderId string + func (*ElectReply) Descriptor() ([]byte, []int) + func (*ElectReply) ProtoMessage() + func (x *ElectReply) GetLeaderAddr() string + func (x *ElectReply) GetLeaderId() string + func (x *ElectReply) ProtoReflect() protoreflect.Message + func (x *ElectReply) Reset() + func (x *ElectReply) String() string + type ElectRequest struct + StaffAddr string + StaffId string + TaskId string + func (*ElectRequest) Descriptor() ([]byte, []int) + func (*ElectRequest) ProtoMessage() + func (x *ElectRequest) GetStaffAddr() string + func (x *ElectRequest) GetStaffId() string + func (x *ElectRequest) GetTaskId() string + func (x *ElectRequest) ProtoReflect() protoreflect.Message + func (x *ElectRequest) Reset() + func (x *ElectRequest) String() string + type Error struct + func (e Error) Error() string + func (e Error) Unwrap() error + type FinishJobReply struct + func (*FinishJobReply) Descriptor() ([]byte, []int) + func (*FinishJobReply) ProtoMessage() + func (x *FinishJobReply) ProtoReflect() protoreflect.Message + func (x *FinishJobReply) Reset() + func (x *FinishJobReply) String() string + type FinishJobRequest struct + JobId string + Message string + Status JobStatus + func (*FinishJobRequest) Descriptor() ([]byte, []int) + func (*FinishJobRequest) ProtoMessage() + func (x *FinishJobRequest) GetJobId() string + func (x *FinishJobRequest) GetMessage() string + func (x *FinishJobRequest) GetStatus() JobStatus + func (x *FinishJobRequest) ProtoReflect() protoreflect.Message + func (x *FinishJobRequest) Reset() + func (x *FinishJobRequest) String() string + type FinishReply struct + func (*FinishReply) Descriptor() ([]byte, []int) + func (*FinishReply) ProtoMessage() + func (x *FinishReply) ProtoReflect() protoreflect.Message + func (x *FinishReply) Reset() + func (x *FinishReply) String() string + type FinishRequest struct + TaskId string + func (*FinishRequest) Descriptor() ([]byte, []int) + func (*FinishRequest) ProtoMessage() + func (x *FinishRequest) GetTaskId() string + func (x *FinishRequest) ProtoReflect() protoreflect.Message + func (x *FinishRequest) Reset() + func (x *FinishRequest) String() string + type Job struct + Content []byte + Id string + Type JobType + func NewJob(ty JobType, pb protobuf.Message) *Job + func NewJobFromBytes(bs []byte) *Job + func (*Job) Descriptor() ([]byte, []int) + func (*Job) ProtoMessage() + func (x *Job) GetContent() []byte + func (x *Job) GetId() string + func (x *Job) GetType() JobType + func (x *Job) ProtoReflect() protoreflect.Message + func (x *Job) Reset() + func (x *Job) String() string + type JobStatus int32 + const JobStatus_Failed + const JobStatus_InvalidJobStatus + const JobStatus_Succeed + func (JobStatus) Descriptor() protoreflect.EnumDescriptor + func (JobStatus) EnumDescriptor() ([]byte, []int) + func (JobStatus) Type() protoreflect.EnumType + func (x JobStatus) Enum() *JobStatus + func (x JobStatus) Number() protoreflect.EnumNumber + func (x JobStatus) String() string + type JobType int32 + const JobType_CopyDir + const JobType_CopyFile + const JobType_CopyMultipart + const JobType_CopyMultipartFile + const JobType_CopySingleFile + const JobType_InvalidJobType + func (JobType) Descriptor() protoreflect.EnumDescriptor + func (JobType) EnumDescriptor() ([]byte, []int) + func (JobType) Type() protoreflect.EnumType + func (x JobType) Enum() *JobType + func (x JobType) Number() protoreflect.EnumNumber + func (x JobType) String() string + type Pair struct + Key string + Value string + func (*Pair) Descriptor() ([]byte, []int) + func (*Pair) ProtoMessage() + func (x *Pair) GetKey() string + func (x *Pair) GetValue() string + func (x *Pair) MarshalGQL(w io.Writer) + func (x *Pair) ProtoReflect() protoreflect.Message + func (x *Pair) Reset() + func (x *Pair) String() string + func (x *Pair) UnmarshalGQL(v interface{}) error + type PollJobReply struct + Job *Job + Status PollJobStatus + func (*PollJobReply) Descriptor() ([]byte, []int) + func (*PollJobReply) ProtoMessage() + func (x *PollJobReply) GetJob() *Job + func (x *PollJobReply) GetStatus() PollJobStatus + func (x *PollJobReply) ProtoReflect() protoreflect.Message + func (x *PollJobReply) Reset() + func (x *PollJobReply) String() string + type PollJobRequest struct + StaffId string + func (*PollJobRequest) Descriptor() ([]byte, []int) + func (*PollJobRequest) ProtoMessage() + func (x *PollJobRequest) GetStaffId() string + func (x *PollJobRequest) ProtoReflect() protoreflect.Message + func (x *PollJobRequest) Reset() + func (x *PollJobRequest) String() string + type PollJobStatus int32 + const PollJobStatus_InvalidPollJobStatus + const PollJobStatus_Terminated + const PollJobStatus_Valid + func (PollJobStatus) Descriptor() protoreflect.EnumDescriptor + func (PollJobStatus) EnumDescriptor() ([]byte, []int) + func (PollJobStatus) Type() protoreflect.EnumType + func (x PollJobStatus) Enum() *PollJobStatus + func (x PollJobStatus) Number() protoreflect.EnumNumber + func (x PollJobStatus) String() string + type PollReply struct + Status PollStatus + Task *Task + func (*PollReply) Descriptor() ([]byte, []int) + func (*PollReply) ProtoMessage() + func (x *PollReply) GetStatus() PollStatus + func (x *PollReply) GetTask() *Task + func (x *PollReply) ProtoReflect() protoreflect.Message + func (x *PollReply) Reset() + func (x *PollReply) String() string + type PollRequest struct + StaffId string + func (*PollRequest) Descriptor() ([]byte, []int) + func (*PollRequest) ProtoMessage() + func (x *PollRequest) GetStaffId() string + func (x *PollRequest) ProtoReflect() protoreflect.Message + func (x *PollRequest) Reset() + func (x *PollRequest) String() string + type PollStatus int32 + const PollStatus_Empty + const PollStatus_InvalidPollStatus + const PollStatus_Terminated + const PollStatus_Valid + func (PollStatus) Descriptor() protoreflect.EnumDescriptor + func (PollStatus) EnumDescriptor() ([]byte, []int) + func (PollStatus) Type() protoreflect.EnumType + func (x PollStatus) Enum() *PollStatus + func (x PollStatus) Number() protoreflect.EnumNumber + func (x PollStatus) String() string + type RegisterReply struct + func (*RegisterReply) Descriptor() ([]byte, []int) + func (*RegisterReply) ProtoMessage() + func (x *RegisterReply) ProtoReflect() protoreflect.Message + func (x *RegisterReply) Reset() + func (x *RegisterReply) String() string + type RegisterRequest struct + StaffId string + func (*RegisterRequest) Descriptor() ([]byte, []int) + func (*RegisterRequest) ProtoMessage() + func (x *RegisterRequest) GetStaffId() string + func (x *RegisterRequest) ProtoReflect() protoreflect.Message + func (x *RegisterRequest) Reset() + func (x *RegisterRequest) String() string + type Staff struct + Id string + func NewStaff(id string) *Staff + func NewStaffFromBytes(bs []byte) *Staff + func (*Staff) Descriptor() ([]byte, []int) + func (*Staff) ProtoMessage() + func (x *Staff) GetId() string + func (x *Staff) ProtoReflect() protoreflect.Message + func (x *Staff) Reset() + func (x *Staff) String() string + type StaffClient interface + Elect func(ctx context.Context, in *ElectRequest, opts ...grpc.CallOption) (*ElectReply, error) + Finish func(ctx context.Context, in *FinishRequest, opts ...grpc.CallOption) (*FinishReply, error) + Poll func(ctx context.Context, in *PollRequest, opts ...grpc.CallOption) (Staff_PollClient, error) + Register func(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterReply, error) + func NewStaffClient(cc grpc.ClientConnInterface) StaffClient + type StaffServer interface + Elect func(context.Context, *ElectRequest) (*ElectReply, error) + Finish func(context.Context, *FinishRequest) (*FinishReply, error) + Poll func(*PollRequest, Staff_PollServer) error + Register func(context.Context, *RegisterRequest) (*RegisterReply, error) + type Staff_PollClient interface + Recv func() (*PollReply, error) + type Staff_PollServer interface + Send func(*PollReply) error + type Storage struct + Options []*Pair + Type StorageType + func (*Storage) Descriptor() ([]byte, []int) + func (*Storage) ProtoMessage() + func (x *Storage) GetOptions() []*Pair + func (x *Storage) GetType() StorageType + func (x *Storage) MarshalGQL(w io.Writer) + func (x *Storage) ProtoReflect() protoreflect.Message + func (x *Storage) Reset() + func (x *Storage) String() string + type StorageType int32 + const StorageType_Fs + const StorageType_InvalidStorageType + const StorageType_Qingstor + func (StorageType) Descriptor() protoreflect.EnumDescriptor + func (StorageType) EnumDescriptor() ([]byte, []int) + func (StorageType) Type() protoreflect.EnumType + func (x *StorageType) UnmarshalGQL(v interface{}) error + func (x StorageType) Enum() *StorageType + func (x StorageType) MarshalGQL(w io.Writer) + func (x StorageType) Number() protoreflect.EnumNumber + func (x StorageType) String() string type Task + Id string + StaffIds []string + Storages []*Storage + func NewTaskFromBytes(bs []byte) *Task + func (*Task) Descriptor() ([]byte, []int) + func (*Task) ProtoMessage() + func (x *Task) GetCreatedAt() *timestamppb.Timestamp + func (x *Task) GetId() string + func (x *Task) GetName() string + func (x *Task) GetOptions() []*Pair + func (x *Task) GetStaffIds() []string + func (x *Task) GetStatus() TaskStatus + func (x *Task) GetStorages() []*Storage + func (x *Task) GetType() TaskType + func (x *Task) GetUpdatedAt() *timestamppb.Timestamp + func (x *Task) ProtoReflect() protoreflect.Message + func (x *Task) Reset() + func (x *Task) String() string + type TaskLeader struct + StaffAddr string + StaffId string + TaskId string + func (*TaskLeader) Descriptor() ([]byte, []int) + func (*TaskLeader) ProtoMessage() + func (x *TaskLeader) GetStaffAddr() string + func (x *TaskLeader) GetStaffId() string + func (x *TaskLeader) GetTaskId() string + func (x *TaskLeader) ProtoReflect() protoreflect.Message + func (x *TaskLeader) Reset() + func (x *TaskLeader) String() string + type TaskReply struct + Id string + Message string + StaffId string + Status uint32 + func (*TaskReply) Descriptor() ([]byte, []int) + func (*TaskReply) ProtoMessage() + func (x *TaskReply) GetId() string + func (x *TaskReply) GetMessage() string + func (x *TaskReply) GetStaffId() string + func (x *TaskReply) GetStatus() uint32 + func (x *TaskReply) ProtoReflect() protoreflect.Message + func (x *TaskReply) Reset() + func (x *TaskReply) String() string type TaskStatus + const TaskStatus_Created + const TaskStatus_Error + const TaskStatus_Finished + const TaskStatus_InvalidTaskStatus + const TaskStatus_Ready + const TaskStatus_Running + const TaskStatus_Stopped + func (TaskStatus) Descriptor() protoreflect.EnumDescriptor + func (TaskStatus) EnumDescriptor() ([]byte, []int) + func (TaskStatus) Type() protoreflect.EnumType + func (x TaskStatus) Enum() *TaskStatus + func (x TaskStatus) Number() protoreflect.EnumNumber type TaskType + const TaskType_CopyDir + const TaskType_InvalidTaskType + func (TaskType) Descriptor() protoreflect.EnumDescriptor + func (TaskType) EnumDescriptor() ([]byte, []int) + func (TaskType) Type() protoreflect.EnumType + func (x TaskType) Enum() *TaskType + func (x TaskType) Number() protoreflect.EnumNumber + type UnimplementedStaffServer struct + func (UnimplementedStaffServer) Elect(context.Context, *ElectRequest) (*ElectReply, error) + func (UnimplementedStaffServer) Finish(context.Context, *FinishRequest) (*FinishReply, error) + func (UnimplementedStaffServer) Poll(*PollRequest, Staff_PollServer) error + func (UnimplementedStaffServer) Register(context.Context, *RegisterRequest) (*RegisterReply, error) + type UnimplementedWorkerServer struct + func (UnimplementedWorkerServer) CreateJob(context.Context, *CreateJobRequest) (*CreateJobReply, error) + func (UnimplementedWorkerServer) FinishJob(context.Context, *FinishJobRequest) (*FinishJobReply, error) + func (UnimplementedWorkerServer) PollJob(*PollJobRequest, Worker_PollJobServer) error + func (UnimplementedWorkerServer) WaitJob(context.Context, *WaitJobRequest) (*WaitJobReply, error) + type UnsafeStaffServer interface + type UnsafeWorkerServer interface + type WaitJobReply struct + Message string + Status uint32 + func (*WaitJobReply) Descriptor() ([]byte, []int) + func (*WaitJobReply) ProtoMessage() + func (x *WaitJobReply) GetMessage() string + func (x *WaitJobReply) GetStatus() uint32 + func (x *WaitJobReply) ProtoReflect() protoreflect.Message + func (x *WaitJobReply) Reset() + func (x *WaitJobReply) String() string + type WaitJobRequest struct + JobId string + func (*WaitJobRequest) Descriptor() ([]byte, []int) + func (*WaitJobRequest) ProtoMessage() + func (x *WaitJobRequest) GetJobId() string + func (x *WaitJobRequest) ProtoReflect() protoreflect.Message + func (x *WaitJobRequest) Reset() + func (x *WaitJobRequest) String() string + type WorkerClient interface + CreateJob func(ctx context.Context, in *CreateJobRequest, opts ...grpc.CallOption) (*CreateJobReply, error) + FinishJob func(ctx context.Context, in *FinishJobRequest, opts ...grpc.CallOption) (*FinishJobReply, error) + PollJob func(ctx context.Context, in *PollJobRequest, opts ...grpc.CallOption) (Worker_PollJobClient, error) + WaitJob func(ctx context.Context, in *WaitJobRequest, opts ...grpc.CallOption) (*WaitJobReply, error) + func NewWorkerClient(cc grpc.ClientConnInterface) WorkerClient + type WorkerServer interface + CreateJob func(context.Context, *CreateJobRequest) (*CreateJobReply, error) + FinishJob func(context.Context, *FinishJobRequest) (*FinishJobReply, error) + PollJob func(*PollJobRequest, Worker_PollJobServer) error + WaitJob func(context.Context, *WaitJobRequest) (*WaitJobReply, error) + type Worker_PollJobClient interface + Recv func() (*PollJobReply, error) + type Worker_PollJobServer interface + Send func(*PollJobReply) error v0.1.0 Mar 29, 2021 Changes in this version + const StatusCreated + const StatusError + const StatusFinished + const StatusRunning + const StatusStopped + const StatusUnknown + var ErrNotFound = errors.New("record not found") + func DbIntoGin(db *DB) gin.HandlerFunc + func NewNotFoundErr(key string) error + type DB struct + func DBFromGin(c *gin.Context) *DB + func NewDB(path string) (*DB, error) + func (d *DB) DeleteTask(id string) error + func (d *DB) GetTask(id string) (*Task, error) + func (d *DB) ListTasks() ([]*Task, error) + func (d *DB) SaveTask(t *Task) error + type Endpoint struct + Options interface{} + Path string + Type ServiceType + type ServiceType string + func (st *ServiceType) Parse(t string) + func (st *ServiceType) UnmarshalGQL(v interface{}) error + func (st ServiceType) MarshalGQL(w io.Writer) + func (st ServiceType) String() string + type Task struct + CreatedAt time.Time + Dst Endpoint + ID string + Name string + Options map[string]interface{} + Src Endpoint + Status TaskStatus + Type TaskType + UpdatedAt time.Time + func NewTask() *Task + func (t Task) FormatKey() []byte + func (t Task) FormatProtoTask() (*proto.Task, error) + type TaskStatus int + func (ts *TaskStatus) IsRunning() bool + func (ts *TaskStatus) Parse(status string) + func (ts *TaskStatus) UnmarshalGQL(v interface{}) error + func (ts TaskStatus) MarshalGQL(w io.Writer) + func (ts TaskStatus) String() string + type TaskType uint32 + func (tt *TaskType) Parse(t string) + func (tt *TaskType) UnmarshalGQL(v interface{}) error + func (tt TaskType) MarshalGQL(w io.Writer) + func (tt TaskType) String() string