teadb

package module
v0.0.0-...-2034602 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(port int, projectID, secret string, cacheEnabled bool)

func RestEntryHandler

func RestEntryHandler(w http.ResponseWriter, r *http.Request, config RestConfig)

func RestGetAllTeasHandler

func RestGetAllTeasHandler(w http.ResponseWriter, r *http.Request, config RestConfig)

func RestTeaHandler

func RestTeaHandler(w http.ResponseWriter, r *http.Request, config RestConfig)

Types

type Cache

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

Cache is a cache struct

func NewCache

func NewCache() (*Cache, error)

NewCache creates a new Cache object

func (*Cache) Add

func (c *Cache) Add(tea Tea)

Add returns a cached tea

func (*Cache) AddAll

func (c *Cache) AddAll(t []Tea)

AddAll caches teas array

func (*Cache) AllTeas

func (c *Cache) AllTeas() ([]Tea, bool)

AllTeas returns the teas

func (*Cache) Invalidate

func (c *Cache) Invalidate()

Invalidate invalidates everything cached

func (*Cache) Tea

func (c *Cache) Tea(id int) (t Tea, ok bool)

Tea returns a cached tea

type GcpClient

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

GcpClient is the client struct

func New

func New(projectID string) (c *GcpClient, err error)

New creates a new GcpClient

func (*GcpClient) AllTeas

func (c *GcpClient) AllTeas() (teas []Tea, err error)

AllTeas retrieves every tea entity

func (*GcpClient) CreateEntry

func (c *GcpClient) CreateEntry(id int, entry TeaEntry) error

CreateEntry creates a new entry on an existing tea

func (*GcpClient) CreateTea

func (c *GcpClient) CreateTea(tea Tea) error

CreateTea creates a new tea entity

func (*GcpClient) DeleteTea

func (c *GcpClient) DeleteTea(teaID int) error

DeleteTea deletes an existing tea

func (*GcpClient) TeaByID

func (c *GcpClient) TeaByID(id int) (t Tea, err error)

TeaByID returns a single tea instance based on its ID

func (*GcpClient) UpdateEntry

func (c *GcpClient) UpdateEntry(id int, entry TeaEntry) error

UpdateEntry updates an existing entry

func (*GcpClient) UpdateTea

func (c *GcpClient) UpdateTea(tea Tea) error

UpdateTea updates a new tea entity

type RestConfig

type RestConfig struct {
	DB                        *GcpClient
	Cache                     *Cache
	Secret, SecretHeaderToken string
	CacheEnabled              bool
}

type Tea

type Tea struct {
	ID               int        `json:"id"`
	Name             string     `json:"name"`
	Timestamp        string     `json:"timestamp"` // TODO
	Date             *time.Time `json:"date"`      // TODO
	Type             string     `json:"type"`
	Region           string     `json:"region"`
	Year             int        `json:"year"`
	Flush            string     `json:"flush"`
	Purchaselocation string     `json:"purchaselocation"`
	Purchasedate     *time.Time `json:"purchasedate"`
	Purchaseprice    float32    `json:"purchaseprice"`
	Comments         string     `json:"comments"`
	Pictures         []string   `json:"pictures"`
	Country          string     `json:"country"`
	Leafgrade        string     `json:"leafgrade"`
	Blendedteas      string     `json:"blendedteas"`
	Blendratio       string     `json:"blendratio"`
	Size             int        `json:"size"`
	Stocked          bool       `json:"stocked"`
	Aging            bool       `json:"aging"`
	Packaging        string     `json:"packaging"`
	Sample           bool       `json:"sample"`
	Entries          []TeaEntry `json:"entries"`
	Progenitor       int        `json:"progenitor"`
}

Tea encapsulates a specific tea and its journal entries

type TeaEntry

type TeaEntry struct {
	Comments          string     `json:"comments"`
	Timestamp         string     `json:"timestamp"`
	Datetime          *time.Time `json:"datetime"`
	Rating            int        `json:"rating"`
	Pictures          []string   `json:"pictures"`
	Steeptime         int        `json:"steeptime"`
	SteepingvesselIdx int        `json:"steepingvessel_idx"`
	Steeptemperature  int        `json:"steeptemperature"` // TODO: in F
	Sessioninstance   string     `json:"sessioninstance"`
	Sessionclosed     bool       `json:"sessionclosed"`
	Fixins            []string   `json:"fixins"`
}

TeaEntry encapsulates the data needed for a journal entry

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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