data

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OrderPrefix is the prefix added to user orders when stored in a database.
	OrderPrefix = "user_order_"

	// DataBaseName is the filename for the program's local storage.
	DataBaseName = "apizza.db"
)

Variables

This section is empty.

Functions

func GetOrder

func GetOrder(name string, db cache.Getter) (*dawg.Order, error)

GetOrder will get an order from a database.

func ListOrders added in v0.0.3

func ListOrders(db cache.MapDB) []string

ListOrders will return a list of orders stored in the database.

func OpenDatabase added in v0.0.3

func OpenDatabase() (*cache.DataBase, error)

OpenDatabase make the default database.

func PrintOrders

func PrintOrders(db cache.MapDB, w io.Writer, verbose bool, color string) error

PrintOrders will print all the names of the saved user orders

func SaveOrder

func SaveOrder(o *dawg.Order, w io.Writer, db cache.Putter) error

SaveOrder will save an order to a database.

Also sends the order to the validation endpoint after saving it to the cache.Putter.

Types

type Decoder added in v0.0.3

type Decoder interface {
	Decode(interface{}) error
}

Decoder is an interface that defines objects that can decode and interface.

type Encoder added in v0.0.3

type Encoder interface {
	Encode(interface{}) error
}

Encoder is an interface that defines objects that are able to Encode and interface.

type MenuCacher interface {
	cache.Updater
	Menu() *dawg.Menu
}

MenuCacher defines an interface that retrieves, caches, and stores menu timestamps.

func NewGobMenuCacher added in v0.0.3

func NewGobMenuCacher(
	decay time.Duration,
	db cache.Storage,
	store func() *dawg.Store,
) MenuCacher

NewGobMenuCacher will create a MenuCacher that will store the menu in a binary format using the "encoding/gob" package.

func NewJSONMenuCacher added in v0.0.3

func NewJSONMenuCacher(
	decay time.Duration,
	db cache.Storage,
	store func() *dawg.Store,
) MenuCacher

NewJSONMenuCacher will create a new MenuCacher that stores the menu as json.

func NewMenuCacher

func NewMenuCacher(
	decay time.Duration,
	db cache.Storage,
	store func() *dawg.Store,
) MenuCacher

NewMenuCacher creates a new MenuCacher.

Jump to

Keyboard shortcuts

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