demo

package
v0.32.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package demo seeds and identifies the public read-only demo account (B7). It is PREVIEW ONLY: Enabled requires RIVOLT_DEMO=true and RIVIAN_CLIENT=replay and RIVOLT_REPLAY_SOURCE=sample, so a production install (live client) never turns it on even if the variable leaks into its environment.

Index

Constants

View Source
const (
	HomeLat   = 34.1613
	HomeLon   = -118.1676
	HomeLabel = "Rose Bowl parking (sample)"
	// HomeRate is the demo's home $/kWh, USD.
	HomeRate = 0.16
)

The demo truck's "home": the sample generator's public, non- residential stadium parking lot (never anyone's address).

View Source
const Username = "rivolt-public-demo"

Username is the demo account's username. It has no @, so it can't collide with a real (email-derived) sign-in, and nobody holds a credential for it: it is only ever reached through the anonymous, read-only allowlist.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled reports whether the demo is on: RIVOLT_DEMO=true on an install running the replay client over the GENERATED sample corpus (RIVOLT_REPLAY_SOURCE=sample). Replaying a recorded vehicle would publish a real person's history anonymously, so anything else fails closed.

func Seed

func Seed(ctx context.Context, d Deps) error

Seed creates (or refreshes) the demo user, its settings, its replay session and a few older charges. Idempotent; safe at every boot. It does nothing unless Enabled.

func SeedCharges

func SeedCharges(uid uuid.UUID, now time.Time) []charges.Charge

SeedCharges are the hand-written older sessions that complete the cost-source set (the replay stream supplies home_rate and network_estimate): Rivian-billed DC fast, user-entered AC, a pending (unpriced) AC session and a home-rate home session. They sit 50-60 days back, before the 45-day replay corpus, so they never overlap a replayed session. Times are day-aligned, so reseeding is stable.

func UserID

func UserID() uuid.UUID

UserID is the demo account's user id.

func VehicleID

func VehicleID() string

VehicleID is the demo vehicle's Rivian id.

Types

type Deps

type Deps struct {
	DB       *sql.DB
	Settings *settings.Factory
	Charges  *charges.Factory
	Secrets  *secrets.Store
	Now      func() time.Time
}

Deps are what Seed writes through.

Jump to

Keyboard shortcuts

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