model

package
v2.0.0-beta.8+incompat... Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2018 License: Apache-2.0 Imports: 11 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseTx

func CloseTx(tx *db.Tx, err error)

CloseTx will close tx with err. If err is nil, we will try to commit this tx. If err is not nil, we will rollback.

func CreateObject

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

CreateObject will create an object in db.

func DeleteJob

func DeleteJob(ctx context.Context, id uint64) (err error)

DeleteJob will delete a job.

func DeleteObject

func DeleteObject(ctx context.Context, p string) (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 GetSequence

func GetSequence(ctx context.Context) (n uint64, err error)

GetSequence will get current bucket's sequence.

func HasJob

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

HasJob will check whether db has not finished job.

func HasObject

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

HasObject will check whether db has not finished object.

func ListJob

func ListJob(ctx context.Context, fn func(*Job)) (err error)

ListJob will list current task's job.

func ListObject

func ListObject(ctx context.Context, fn func(*Object)) (err error)

ListObject will list current task's object.

func NextSequence

func NextSequence(ctx context.Context) (n uint64, err error)

NextSequence will return bucket's next sequence.

Types

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.

func (*Endpoint) Check

func (e *Endpoint) Check() error

Check will check whether current endpoint is valid.

type Job

type Job struct {
	ID     uint64 `msgpack:"id"`
	Path   string `msgpack:"p"`
	Marker string `msgpack:"m"`
}

Job stores job status.

func CreateJob

func CreateJob(ctx context.Context, p string) (j *Job, err error)

CreateJob will create a new job.

func GetJob

func GetJob(ctx context.Context, id uint64) (j *Job, err error)

GetJob will get a job by it's ID.

func (*Job) Save

func (j *Job) Save(ctx context.Context) (err error)

Save will save current job to DB.

type Object

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

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

Object stores object info.

func GetObject

func GetObject(ctx context.Context, p string) (o *Object, err error)

GetObject will get an object from db.

type Task

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

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

	IgnoreExisting bool `yaml:"ignore_existing" msgpack:"ie"`

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

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(s 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