config

package
v0.0.0-...-092d437 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

config holds all application configuration primitives

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CafeConfig

type CafeConfig struct {
	FirstOrderTime      CafeTime      `json:"first_order_time"`
	LastOrderTime       CafeTime      `json:"last_order_time"`
	TimeLocation        *CafeLocation `json:"time_location"`
	TimeSlotIntervalMin int           `json:"time_slot_interval_min"`

	// OrderChan is a public channel name in a form of @channelname
	// or a private channel id. See how to get private channel id:
	// https://github.com/python-telegram-bot/python-telegram-bot/issues/538
	OrderChan string `json:"orders_channel"`
	Menu      Menu   `json:"menu"`
}

type CafeLocation

type CafeLocation time.Location

func (*CafeLocation) UnmarshalJSON

func (l *CafeLocation) UnmarshalJSON(data []byte) error

type CafeTime

type CafeTime time.Time

CafeTime exists only because we need to unmarshal string of type HH:MM into time.Time. It is possible only by having custom named type with its own json.Unmarshaler implementation

func (*CafeTime) UnmarshalJSON

func (c *CafeTime) UnmarshalJSON(data []byte) error

type Config

type Config struct {
	Port       string `short:"p" long:"port" description:"port to listen on" default:"8080"`
	TgAPIToken string `long:"tg-api-token" description:"telegram bot api token" env:"TG_API_TOKEN"`
	LogLevel   string `long:"log-level" description:"log level for all subsystems {trace, debug, info, error, critical}" default:"info"`

	CafeConfigFile string `long:"cafe-config" description:"cafe config file path" default:"cafe.json"`

	Cafe CafeConfig
}

Config holds all application configuration data

func Load

func Load() (Config, error)

type Meal

type Meal struct {
	Val  string
	Hash string
}

func (*Meal) UnmarshalJSON

func (m *Meal) UnmarshalJSON(data []byte) error
type Menu struct {
	Map        map[string][]Meal
	Categories []string
}
func (m *Menu) MealByHash(hash string) (string, bool)
func (m *Menu) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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