driver

package
v0.1.4-0...-18142db Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator interface {
	// Next advances the iterator to the next value, which will then be available through
	// then the Value method. It returns false if no further advancement is possible.
	Next() bool
	// Value returns the current job.
	Value() Job
	// Error returns the current error.
	Error() error
	// Close the iterator
	Close()
}

Iterator define the job iterator interface

type Job

type Job struct {
	ID      int64  `json:"job_id"`
	Name    string `json:"name"`     // The job name, this is unique.
	Func    string `json:"func"`     // The job function reffer on worker function
	Args    string `json:"workload"` // Job args
	Timeout int64  `json:"timeout"`  // Job processing timeout
	SchedAt int64  `json:"sched_at"` // When to sched the job.
	RunAt   int64  `json:"run_at"`   // The job is start at
	Counter int64  `json:"counter"`  // The job run counter
	Status  string `json:"status"`
}

Job workload.

func Decode

func Decode(payload []byte) (job Job, err error)

Decode create a job from bytes

func NewJob

func NewJob(payload []byte) (job Job, err error)

NewJob create a job from json bytes

func (Job) Bytes

func (job Job) Bytes() (data []byte)

Bytes encode job to json bytes

func (Job) Encode

func (job Job) Encode() []byte

Encode job to bytes

func (Job) IsProc

func (job Job) IsProc() bool

IsProc check job status processing

func (Job) IsReady

func (job Job) IsReady() bool

IsReady check job status ready

func (*Job) SetProc

func (job *Job) SetProc()

SetProc set job status processing

func (*Job) SetReady

func (job *Job) SetReady()

SetReady set job status ready

type MemIterator

type MemIterator struct {
	// contains filtered or unexported fields
}

MemIterator define a memory store driver iterator

func (*MemIterator) Close

func (iter *MemIterator) Close()

Close the iterator

func (*MemIterator) Error

func (iter *MemIterator) Error() error

Error returns the current error.

func (*MemIterator) Next

func (iter *MemIterator) Next() bool

Next advances the iterator to the next value, which will then be available through then the Value method. It returns false if no further advancement is possible.

func (*MemIterator) Value

func (iter *MemIterator) Value() Job

Value returns the current job.

type MemStoreDriver

type MemStoreDriver struct {
	// contains filtered or unexported fields
}

MemStoreDriver defined a memory store driver

func NewMemStroeDriver

func NewMemStroeDriver() *MemStoreDriver

NewMemStroeDriver create a memory store driver

func (*MemStoreDriver) Close

func (m *MemStoreDriver) Close() error

Close the driver

func (*MemStoreDriver) Delete

func (m *MemStoreDriver) Delete(jobID int64) (err error)

Delete a job with job id.

func (*MemStoreDriver) Get

func (m *MemStoreDriver) Get(jobID int64) (job Job, err error)

Get a job with job id.

func (*MemStoreDriver) GetOne

func (m *MemStoreDriver) GetOne(Func, name string) (job Job, err error)

GetOne get a job with func and name.

func (*MemStoreDriver) NewIterator

func (m *MemStoreDriver) NewIterator(Func []byte) Iterator

NewIterator create a job Iterator with func or nil.

func (*MemStoreDriver) Save

func (m *MemStoreDriver) Save(job *Job, force ...bool) (err error)

Save job. when job is exists update it, other create one.

type StoreDriver

type StoreDriver interface {
	// Save job. when job is exists update it, other create one.
	Save(*Job, ...bool) error
	// Delete a job with job id.
	Delete(jobID int64) error
	// Get a job with job id.
	Get(jobID int64) (Job, error)
	// GetOne get a job with func and name.
	GetOne(string, string) (Job, error)
	// NewIterator create a job Iterator with func or nil.
	NewIterator([]byte) Iterator
	// Close the driver
	Close() error
}

StoreDriver define the general store interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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