storage

package
v0.0.0-...-022f881 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const COLLECTION_NAME string = "task_store"
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 MongoDBConfig

type MongoDBConfig struct {
	ConnectionUrl string
	Db            string
}

MongoDBConfig is the config structure holding information about mongo db.

type MongoDBStorage

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

MongoDBStorage is the structure responsible for handling mongo storage.

func NewMongoDBStorage

func NewMongoDBStorage(config MongoDBConfig) *MongoDBStorage

NewMongoDBStorage returns a new instance of MongoDBStorage.

func (MongoDBStorage) Add

func (mongodb MongoDBStorage) Add(task TaskAttributes) error

Stores the task to mongo

func (*MongoDBStorage) Close

func (mongodb *MongoDBStorage) Close() error

Close will close the open DB file.

func (*MongoDBStorage) Connect

func (mongodb *MongoDBStorage) Connect() error

Connect creates the database file.

func (MongoDBStorage) Fetch

func (mongodb MongoDBStorage) Fetch() ([]TaskAttributes, error)

Fetch will return the list of all stored tasks.

func (*MongoDBStorage) Initialize

func (mongodb *MongoDBStorage) Initialize() error

Initialize mongodb collection

func (MongoDBStorage) Remove

func (mongodb MongoDBStorage) Remove(task TaskAttributes) error

Remove will delete the task from storage.

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 Sqlite3Config

type Sqlite3Config struct {
	DbName string
}

Sqlite3Config is the config structure holding information about sqlite db.

type Sqlite3Storage

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

Sqlite3Storage is the structure responsible for handling sqlite3 storage.

func NewSqlite3Storage

func NewSqlite3Storage(config Sqlite3Config) Sqlite3Storage

NewSqlite3Storage returns a new instance of Sqlite3Storage.

func (Sqlite3Storage) Add

func (sqlite Sqlite3Storage) Add(task TaskAttributes) error

Add stores the task to sqlite.

func (Sqlite3Storage) Close

func (sqlite Sqlite3Storage) Close() error

Close will close the open DB file.

func (*Sqlite3Storage) Connect

func (sqlite *Sqlite3Storage) Connect() error

Connect creates the database file.

func (Sqlite3Storage) Fetch

func (sqlite Sqlite3Storage) Fetch() ([]TaskAttributes, error)

Fetch will return the list of all stored tasks.

func (*Sqlite3Storage) Initialize

func (sqlite *Sqlite3Storage) Initialize() error

Initialize will run once to initialize the state of the database into the required one. In this case, it'll create the tables required to store task information.

func (Sqlite3Storage) Remove

func (sqlite Sqlite3Storage) Remove(task TaskAttributes) error

Remove will delete the task from storage.

type TaskAttributes

type TaskAttributes struct {
	Hash        string
	Name        string
	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(TaskAttributes) error
	Fetch() ([]TaskAttributes, error)
	Remove(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