base

package
v0.0.2-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePrice

func ParsePrice(str string) (int64, error)

Types

type CanteenMenu

type CanteenMenu struct {
	Canteen string
	Meals   []Meal
}

type CanteenMetadata

type CanteenMetadata struct {
	// A unique identifier for the canteen in the given provider
	ID string

	// The label of the canteen.
	Label string

	// Meta is a map of arbitrary key-value pairs that can be used to store
	// additional information about the canteen.
	Meta map[string]string
}

type CanteenRef

type CanteenRef struct {
	// Meta is a map of arbitrary key-value pairs that can be used to store
	// additional information about the canteen.
	Meta map[string]string

	// The ID of the canteen
	ID string
}

type Meal

type Meal struct {
	Label       string
	Description []string
	Prices      MealPrices
}

type MealPrices

type MealPrices struct {
	Student int64
	Staff   int64
	Extern  int64
}

type Provider

type Provider interface {
	// A unique identifier for the provider.
	Id() string

	// A human readable name for the provider.
	Label() string

	// List all menus of the given canteens for the given date and daytime.
	FetchMenus(ctx context.Context, canteens []CanteenRef, date string, daytime string, lang string) ([]CanteenMenu, error)

	// List all canteens fo this provider
	FetchCanteens(ctx context.Context, lang string) ([]CanteenMetadata, error)
}

type Store

type Store struct {
	Data storage.Root
	// contains filtered or unexported fields
}

func NewStore

func NewStore(base string) (*Store, error)

Create new sync

func (*Store) Close

func (s *Store) Close() error

func (*Store) Filter

func (s *Store) Filter(ctx context.Context, lang string, keyword string) ([]*storage.CanteenData, error)

func (*Store) IsEmpty

func (s *Store) IsEmpty(lang string) bool

func (*Store) Lock

func (s *Store) Lock() error

func (*Store) Open

func (s *Store) Open() error

func (*Store) Read

func (s *Store) Read() error

func (*Store) Sync

func (s *Store) Sync(ctx context.Context, providers []Provider, lang string) error

Initialize sync

func (*Store) Unlock

func (s *Store) Unlock() error

func (*Store) Write

func (s *Store) Write() error

Jump to

Keyboard shortcuts

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