model

package
v2.0.5+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateObject

func CreateObject(ctx context.Context, o Object) (err error)

CreateObject will create an object in db.

func DeleteObject

func DeleteObject(ctx context.Context, o Object) (err error)

DeleteObject will delete an object.

func DeleteTask

func DeleteTask(ctx context.Context) (err error)

DeleteTask will delete a task from content.

func DeleteTaskByName

func DeleteTaskByName(ctx context.Context, p string) (err error)

DeleteTaskByName will delete a task by it's name.

func HasDirectoryObject

func HasDirectoryObject(ctx context.Context) (b bool, err error)

HasDirectoryObject will check whether db has not finished directory object.

func HasPartialObject

func HasPartialObject(ctx context.Context) (b bool, err error)

HasPartialObject will check whether db has not finished partial object.

func HasParts

func HasParts(ctx context.Context, key string) (b bool, err error)

HasParts will check whether specific key has not finished parts.

func HasSingleObject

func HasSingleObject(ctx context.Context) (b bool, err error)

HasSingleObject will check whether db has not finished single object.

Types

type DirectoryObject

type DirectoryObject struct {
	Key    string `msgpack:"p"`
	Marker string `msgpack:"m"`
}

DirectoryObject is the object for directory.

func NextDirectoryObject

func NextDirectoryObject(ctx context.Context, p string) (o *DirectoryObject, err error)

NextDirectoryObject will return the next directory object after p.

func (*DirectoryObject) Type

func (o *DirectoryObject) Type() string

Type implement Object.Type

type Endpoint

type Endpoint struct {
	Type    string                 `yaml:"type" msgpack:"t"`
	Path    string                 `yaml:"path" msgpack:"p"`
	Options map[string]interface{} `yaml:"options" msgpack:"o"`
}

Endpoint store data for endpoint.

type Object

type Object interface {
	Type() string
}

Object is the interface for object.

type PartialObject

type PartialObject struct {
	Key string `msgpack:"p"`

	Size   int64  `msgpack:"s"`
	Offset int64  `msgpack:"of"`
	MD5    string `msgpack:"cm"`

	TotalNumber int    `msgpack:"tn"`
	PartNumber  int    `msgpack:"pn"`
	UploadID    string `msgpack:"uid"`
}

PartialObject is a partial object.

func NextPartialObject

func NextPartialObject(ctx context.Context, p string, partNumber int) (o *PartialObject, err error)

NextPartialObject will return the next single object after p.

func (*PartialObject) Type

func (o *PartialObject) Type() string

Type implement Object.Type

type SingleObject

type SingleObject struct {
	Key string `msgpack:"p"`

	Size         int64  `msgpack:"s"`
	LastModified int64  `msgpack:"lm"`
	MD5          string `msgpack:"cm"`
}

SingleObject is a single object.

func NextSingleObject

func NextSingleObject(ctx context.Context, p string) (o *SingleObject, err error)

NextSingleObject will return the next single object after p.

func (*SingleObject) Type

func (o *SingleObject) Type() string

Type implement Object.Type

type Task

type Task struct {
	Type string `yaml:"type" msgpack:"t"`

	Src *Endpoint `yaml:"source" msgpack:"src"`
	Dst *Endpoint `yaml:"destination" msgpack:"dst"`

	IgnoreExisting        string `yaml:"ignore_existing" msgpack:"ie"`
	MultipartBoundarySize int64  `yaml:"multipart_boundary_size" msgpack:"mbs"`

	// Data that only stores in database.
	Name   string `yaml:"-" msgpack:"n"`
	Status string `yaml:"-" msgpack:"s"`

	// Date that only keep in memory.
	Handle func(ctx context.Context, o Object) (err error) `yaml:"-" msgpack:"-"`
}

Task store all data for a task.

func GetTask

func GetTask(ctx context.Context) (t *Task, err error)

GetTask will get task by it's name.

func GetTaskByName

func GetTaskByName(ctx context.Context, p string) (t *Task, err error)

GetTaskByName will get task by it's name.

func ListTask

func ListTask(ctx context.Context) (t []*Task, err error)

ListTask will list all tasks.

func LoadTask

func LoadTask(name, taskPath string) (t *Task, err error)

LoadTask will try to load task from database and file.

func LoadTaskFromContent

func LoadTaskFromContent(content []byte) (t *Task, err error)

LoadTaskFromContent will load config from file content.

func LoadTaskFromFilePath

func LoadTaskFromFilePath(filePath string) (t *Task, err error)

LoadTaskFromFilePath will load config from specific file path.

func (*Task) Check

func (t *Task) Check() error

Check will check whether current task is valid.

func (*Task) Save

func (t *Task) Save(ctx context.Context) (err error)

Save will save current task in DB.

func (*Task) Sum256

func (t *Task) Sum256() [sha256.Size]byte

Sum256 will calculate task's sha256.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL