model

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

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

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

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 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 GetCurrentJobID

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

GetCurrentJobID will get current job ID.

func GetSequence

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

GetSequence will get current bucket's sequence.

func HasObject

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

HasObject will check whether db has not finished object.

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.

func UpdateCurrentJobID

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

UpdateCurrentJobID will update current job ID.

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"`
	Status string `msgpack:"s"`
}

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"`
	ContentMD5   []byte `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"`

	Overwrite        bool `yaml:"overwrite" msgpack:"o"`
	IgnoreExisting   bool `yaml:"ignore_existing" msgpack:"ie"`
	IgnoreUnmodified bool `yaml:"ignore_unmodified" msgpack:"iu"`

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

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