storage

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: GPL-3.0 Imports: 7 Imported by: 6

Documentation

Overview

Package storage implements a wrapper using the yaml file as "backend"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Helper

type Helper struct {
	Mutex *sync.RWMutex
}

Helper struct to sync access to the storage

func (*Helper) AddAlarm

func (storageHelper *Helper) AddAlarm(alarm types.Alarm) ([]types.Alarm, error)

AddAlarm adds a given alarm

func (*Helper) DeleteAlarm

func (storageHelper *Helper) DeleteAlarm(alarmIdx int) ([]types.Alarm, error)

DeleteAlarm delets the alarm on the given index

func (*Helper) GetAlarm

func (storageHelper *Helper) GetAlarm(idx int, withWritePermission bool) (types.Alarm, error)

GetAlarm returns the alarn on the given index

func (*Helper) GetAlarms

func (storageHelper *Helper) GetAlarms(withWritePermission bool) ([]types.Alarm, error)

GetAlarms returns all the alarms

func (*Helper) GetRadio

func (storageHelper *Helper) GetRadio(withWritePermission bool) (types.Radio, error)

GetRadio returns the radio resource

func (*Helper) GetSettings

func (storageHelper *Helper) GetSettings() (Settings, error)

GetSettings returns the setings stored in the file

func (*Helper) SaveAlarm

func (storageHelper *Helper) SaveAlarm(idx int, alarm types.Alarm) (types.Alarm, error)

SaveAlarm savest tha given alarm at the given index to the storage

func (*Helper) SaveRadio

func (storageHelper *Helper) SaveRadio(radio types.Radio) (types.Radio, error)

SaveRadio saves given radio as the radio resource

func (*Helper) SaveStoredData

func (storageHelper *Helper) SaveStoredData(data RpiRadioAlarmData)

SaveStoredData save the data to storage and releases the lock

func (*Helper) SwitchRadio

func (storageHelper *Helper) SwitchRadio(running bool) (types.Radio, error)

SwitchRadio switches the radio to running if true is passed

type RpiRadioAlarmData

type RpiRadioAlarmData struct {
	Settings Settings      `yaml:"settings"`
	Alarms   []types.Alarm `yaml:"alarms"`
	Radio    types.Radio   `yaml:"radio"`
}

RpiRadioAlarmData contains all the data for the RpiRadioAlarm

type Settings

type Settings struct {
	Port           int  `yaml:"port"`
	RunAPI         bool `yaml:"run_api"`
	RunTelegrambot bool `yaml:"run_telegram_bot"`
	RunDiscordbot  bool `yaml:"run_discord_bot"`
}

Settings contains specific settings for the program

Jump to

Keyboard shortcuts

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