storage

package
v0.0.0-...-d772fc0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltDB

type BoltDB struct {
	BoltPath string
	Timeout  time.Duration
	DB       *bolt.DB
}

BoltDB client to store jobs on database

func NewBoltDB

func NewBoltDB(path string, timeout time.Duration) (*BoltDB, error)

NewBoltDB creates a boltdb client

func (*BoltDB) AuthenticationTokenExists

func (c *BoltDB) AuthenticationTokenExists(token string) bool

AuthenticationTokenExists Checks if an authentication token exists on boltdb

func (*BoltDB) Close

func (c *BoltDB) Close() error

Close closes boltdb connection to database

func (*BoltDB) DeleteAuthenticationToken

func (c *BoltDB) DeleteAuthenticationToken(token string) error

DeleteAuthenticationToken Deletes an authentication token from boltdb, doesn't return error if doesnt exists

func (*BoltDB) DeleteJob

func (c *BoltDB) DeleteJob(j *job.Job) error

DeleteJob deletes an HTTP job and all its results from boltdb, doesn't return error if job doesn't exists

func (*BoltDB) DeleteResult

func (c *BoltDB) DeleteResult(r *job.Result) error

DeleteResult deletes a result from boltdv, doesn't return error if result doesn't exist

func (*BoltDB) GetJob

func (c *BoltDB) GetJob(id int) (*job.Job, error)

GetJob returns an specific HTTP job based on the ID

func (*BoltDB) GetJobs

func (c *BoltDB) GetJobs(low, high int) ([]*job.Job, error)

GetJobs returns all the HTTP jobs from boltdb. Use low and high params as slice operator

func (*BoltDB) GetResult

func (c *BoltDB) GetResult(j *job.Job, id int) (*job.Result, error)

GetResult retursn a single result from boltdb

func (*BoltDB) GetResults

func (c *BoltDB) GetResults(j *job.Job, low, high int) ([]*job.Result, error)

GetResults returns all the results of a jobs from boltdb. Use low and high params as slice operator

func (*BoltDB) JobsLength

func (c *BoltDB) JobsLength() int

JobsLength returns the number of jobs stored on boltdb

func (*BoltDB) ResultsLength

func (c *BoltDB) ResultsLength(j *job.Job) int

ResultsLength returns the number of results(of a job) stored in boltdb

func (*BoltDB) SaveAuthenticationToken

func (c *BoltDB) SaveAuthenticationToken(token string) error

SaveAuthenticationToken stores an authentication token on boltdb

func (*BoltDB) SaveJob

func (c *BoltDB) SaveJob(j *job.Job) error

SaveJob stores an HTTP job on boltdb

func (*BoltDB) SaveResult

func (c *BoltDB) SaveResult(r *job.Result) error

SaveResult stores a result of a job on boltdb

type Client

type Client interface {
	Close() error

	// Job actions
	// GetJobs returns an slice of job instances; the low parmeter will be the
	// first job and the high will be the next one to the last job that will be
	// returned; this acts like an slice operator. 0 on high parameter means all.
	// this would be translated as jobs[low:] and 0 on low would be jobs[:high]
	GetJobs(low, high int) ([]*job.Job, error)

	// GetJob returns a job by ID
	GetJob(id int) (*job.Job, error)

	// SaveJob stores the job; this method works as an insert or update, the
	// method will know if the job needs to be updated or inserted by identifying
	// the presence of the ID. This wil save as a batch so on an update the
	// instance should have all the fields set
	SaveJob(j *job.Job) error

	// DeleteJob deletes a job
	DeleteJob(j *job.Job) error

	// JobsLength returns the number of jobs stored
	JobsLength() int

	// Result actions
	// GetResults returns an slice of results from a job; The low parmeter will be the
	// first result and the high will be the next one to the last result that will be
	// returned; this acts like an slice operator. 0 on high parameter means all.
	// this would be translated as results[low:] and 0 on low would be results[:high]
	GetResults(j *job.Job, low, high int) ([]*job.Result, error)

	// GetResult returns a result based on the result id of a job
	GetResult(j *job.Job, id int) (*job.Result, error)

	// SaveResult stores the result.  Results cannot be updated
	SaveResult(r *job.Result) error

	// DeleteResult deletes a result
	DeleteResult(r *job.Result) error

	// ResultsLength returns the number of results (of a job) stored
	ResultsLength(j *job.Job) int

	// SaveAuthenticationToken stores an authentication token on database
	SaveAuthenticationToken(token string) error

	// DeleteAuthenticationToken Deletes an authentication token from database
	DeleteAuthenticationToken(token string) error

	// AuthenticationTokenExists Checks if an authentication token exists
	AuthenticationTokenExists(token string) bool
}

Client implements the client of an storage

type Dummy

type Dummy struct {
	Jobs       map[string]*job.Job
	JobCounter int

	Results        map[string]map[string]*job.Result
	ResultsCounter map[string]int

	TokenMutex *sync.Mutex
	Tokens     map[string]struct{}
	// contains filtered or unexported fields
}

Dummy implements the Storage interface everything to a local memory map

func NewDummy

func NewDummy() *Dummy

NewDummy creates a client that stores on memory

func (*Dummy) AuthenticationTokenExists

func (c *Dummy) AuthenticationTokenExists(token string) bool

AuthenticationTokenExists Checks if an authentication token exists

func (*Dummy) Close

func (c *Dummy) Close() error

Close doens't do nothing on dummy client

func (*Dummy) DeleteAuthenticationToken

func (c *Dummy) DeleteAuthenticationToken(token string) error

DeleteAuthenticationToken Deletes an authentication token from database

func (*Dummy) DeleteJob

func (c *Dummy) DeleteJob(j *job.Job) error

DeleteJob Deletes a job on memory

func (*Dummy) DeleteResult

func (c *Dummy) DeleteResult(r *job.Result) error

DeleteResult deletes a job on ajob in memory

func (*Dummy) GetJob

func (c *Dummy) GetJob(id int) (job *job.Job, err error)

GetJob returns a job from memory

func (*Dummy) GetJobs

func (c *Dummy) GetJobs(low, high int) (jobs []*job.Job, err error)

GetJobs returns all the http jobs stored on memory

func (*Dummy) GetResult

func (c *Dummy) GetResult(j *job.Job, id int) (*job.Result, error)

GetResult returns a result from a job on memory

func (*Dummy) GetResults

func (c *Dummy) GetResults(j *job.Job, low, high int) ([]*job.Result, error)

GetResults returns results from a job on memory

func (*Dummy) JobsLength

func (c *Dummy) JobsLength() int

JobsLength returns the number of jobs stored

func (*Dummy) ResultsLength

func (c *Dummy) ResultsLength(j *job.Job) int

ResultsLength returns the number of results stored

func (*Dummy) SaveAuthenticationToken

func (c *Dummy) SaveAuthenticationToken(token string) error

SaveAuthenticationToken stores an authentication token on database

func (*Dummy) SaveJob

func (c *Dummy) SaveJob(j *job.Job) error

SaveJob stores a job on memory

func (*Dummy) SaveResult

func (c *Dummy) SaveResult(r *job.Result) error

SaveResult saves a result on a job in memory

func (*Dummy) UpdateJob

func (c *Dummy) UpdateJob(j *job.Job) error

UpdateJob updates a present job on memory

Jump to

Keyboard shortcuts

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