Documentation
¶
Overview ¶
Package store keeps the saved state of sites: one SQLite database per site in the data directory (see docs/adr/0002 and 0003). The process that runs a site writes to its database; other commands read it, or change it while the site is not running.
Index ¶
- Variables
- func Delete(dataDir, siteName string) error
- func Exists(dataDir, siteName string) bool
- func LogPath(dataDir, siteName string) string
- func OutputPath(dataDir, siteName string) string
- func Path(dataDir, siteName string) string
- type Change
- type Charger
- type Meta
- type Site
- type Spec
- type Store
- func (st *Store) Apply(change Change) error
- func (st *Store) Chargers() ([]Charger, error)
- func (st *Store) Close() error
- func (st *Store) Load() (Site, error)
- func (st *Store) LoadState(id string) (*charger.State, error)
- func (st *Store) Meta() (Meta, error)
- func (st *Store) Remove(id string) error
- func (st *Store) SaveState(id string, state charger.State) error
- func (st *Store) SetMeta(meta Meta) error
- func (st *Store) SetPower(ids []string) error
Constants ¶
This section is empty.
Variables ¶
var ErrNoSite = errors.New("the site has no saved state")
ErrNoSite is returned when a site has no saved state.
Functions ¶
func LogPath ¶
LogPath returns the file a site logs to. When it is full it is rotated to files of the same name with a number added.
func OutputPath ¶
OutputPath returns the file that takes what the background process of a site prints, which is only what goes wrong with the process itself.
Types ¶
type Change ¶
type Change struct {
// Put creates chargers or replaces their name, power and spec. The
// state of an existing charger is kept.
Put []Charger
// Reset wipes the state of chargers, which keep their name.
Reset []string
// Remove deletes chargers.
Remove []string
}
Change is a set of changes to a site's chargers that is applied as a whole or not at all.
type Charger ¶
type Charger struct {
// ID is the charge point ID.
ID string
Name string
// Power says whether the charger is to be powered on when the site's
// process starts.
Power bool
Spec Spec
// State is nil for a charger that has never run.
State *charger.State
}
Charger is a saved charger.
type Meta ¶
type Meta struct {
Name string `json:"name"`
// File is the site file the site was last brought up from. It is empty
// for the implicit site of "plugyard run".
File string `json:"file,omitempty"`
// Implicit marks the site of a charger started with "plugyard run".
Implicit bool `json:"implicit,omitempty"`
// Down says the site was taken down: its chargers are no longer listed,
// though their state is kept.
Down bool `json:"down,omitempty"`
Speed float64 `json:"speed,omitempty"`
ConnectRate float64 `json:"connectRate,omitempty"`
EVs map[string]ev.Overrides `json:"evs,omitempty"`
// LogMaxSize and LogFiles cap the site's log: at most LogFiles files of
// LogMaxSize bytes. Zero stands for the defaults.
LogMaxSize int64 `json:"logMaxSize,omitempty"`
LogFiles int `json:"logFiles,omitempty"`
// AllowUploads lists the hosts diagnostics may be uploaded to besides
// the machine the CSMS is on.
AllowUploads []string `json:"allowUploads,omitempty"`
// UploadsInsecureSkipVerify turns off the check of the certificate of
// an https or ftps server diagnostics are uploaded to.
UploadsInsecureSkipVerify bool `json:"uploadsInsecureSkipVerify,omitempty"`
}
Meta is what is saved about a site as a whole.
type Spec ¶
type Spec struct {
Model *model.Model `json:"model"`
CSMSURL string `json:"csmsUrl"`
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
// HasPassword says the charger authenticates with a password. The
// password itself is never saved.
HasPassword bool `json:"hasPassword,omitempty"`
// EV names the EV preset used when a plug does not name one.
EV string `json:"ev,omitempty"`
}
Spec is the snapshot of the files a charger was created from.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the open database of one site.
func OpenExisting ¶
OpenExisting opens the saved state of a site, or returns ErrNoSite.
func OpenMemory ¶
OpenMemory returns a store that keeps nothing on disk, for a charger that is to leave no trace.
func (*Store) LoadState ¶
LoadState returns the saved state of a charger, or nil if it has never run.