storage

package
v0.0.0-...-524ddad Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const TaskStoreBucket string = "task_store"

Variables

This section is empty.

Functions

func NewPostgresStorage

func NewPostgresStorage(config PostgresDBConfig) (postgres *postgresStorage, err error)

creates new instance of postgres DB

Types

type BoltDBConfig

type BoltDBConfig struct {
	DBPath string
}

BoltDBConfig is the config structure holding information about boltdb db.

type BoltDBStorage

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

BoltDBStorage is the structure responsible for handling boltdb storage.

func NewBoltDBStorage

func NewBoltDBStorage(config BoltDBConfig) *BoltDBStorage

NewBoltDBStorage returns a new instance of BoltDBStorage.

func (*BoltDBStorage) Add

func (b *BoltDBStorage) Add(task TaskAttributes) error

Add stores the task to boltdb.

func (*BoltDBStorage) Close

func (b *BoltDBStorage) Close() error

Close will close the open DB file.

func (*BoltDBStorage) Connect

func (b *BoltDBStorage) Connect() error

Connect opens the database file, or creates it if it does not exist.

func (*BoltDBStorage) Fetch

func (b *BoltDBStorage) Fetch() ([]TaskAttributes, error)

Fetch will return the list of all stored tasks.

func (*BoltDBStorage) Remove

func (b *BoltDBStorage) Remove(task TaskAttributes) error

Remove will delete the task from boltdb storage.

type MemoryStorage

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

MemoryStorage is a memory task store

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage returns an instance of MemoryStorage.

func (*MemoryStorage) Add

func (memStore *MemoryStorage) Add(task TaskAttributes) error

Add adds a task to the memory store.

func (*MemoryStorage) Close

func (memStore *MemoryStorage) Close() error

func (*MemoryStorage) Fetch

func (memStore *MemoryStorage) Fetch() ([]TaskAttributes, error)

Fetch will return all tasks stored.

func (*MemoryStorage) Remove

func (memStore *MemoryStorage) Remove(task TaskAttributes) error

Remove will remove task from store

type NoOpStorage

type NoOpStorage struct {
}

NoOpStorage is an ineffective storage which can be used to prevent storing tasks altogether.

func NewNoOpStorage

func NewNoOpStorage() NoOpStorage

NewNoOpStorage returns an instance of NoOpStorage

func (NoOpStorage) Add

func (noop NoOpStorage) Add(task TaskAttributes) error

Add does nothing

func (NoOpStorage) Close

func (noop NoOpStorage) Close() error

func (NoOpStorage) Fetch

func (noop NoOpStorage) Fetch() ([]TaskAttributes, error)

Fetch returns an empty list of tasks

func (NoOpStorage) Remove

func (noop NoOpStorage) Remove(task TaskAttributes) error

Remove does nothing

type PostgresDBConfig

type PostgresDBConfig struct {
	DbURL string
}

type TaskAttributes

type TaskAttributes struct {
	Hash        string `storm:"id"`
	Name        string `storm:"unique,index"`
	LastRun     string
	NextRun     string
	Duration    string
	IsRecurring string
	Params      string
}

TaskAttributes is a struct which is used to transfer data from/to stores. All task data are converted from/to string to prevent the store from worrying about details of converting data to the proper formats.

type TaskStore

type TaskStore interface {
	Add(task TaskAttributes) error
	Fetch() ([]TaskAttributes, error)
	Remove(task TaskAttributes) error
	Close() error
}

TaskStore is the interface to implement when adding custom task storage.

Jump to

Keyboard shortcuts

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