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
- func ApplySampleUserPrices(ctx context.Context, d *sql.DB, store pricer) (int, error)
- func Enabled() bool
- func PriceCandidates(ctx context.Context, cands []PriceCandidate, store pricer) (int, error)
- func RunPricing(ctx context.Context, d *sql.DB, store pricer, every time.Duration, ...)
- func Seed(ctx context.Context, d Deps) error
- func SeedCharges(uid uuid.UUID, now time.Time) []charges.Charge
- func UserID() uuid.UUID
- func VehicleID() string
- type Deps
- type PriceCandidate
Constants ¶
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).
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 ApplySampleUserPrices ¶ added in v0.33.0
ApplySampleUserPrices gives the demo truck's hand-priced session (the Las Vegas hotel L2, a flat $15 in the sample corpus) its user price after replay has recorded it. The recorder cannot invent a price only a person enters, so this is the demo's stand-in for that person. It uses the same store path as PATCH /charges/{id}/pricing, which stamps cost_source = user.
Only CLOSED charges with no cost source are touched: an open charge is still being upserted by the recorder, which would overwrite the price. Idempotent; returns how many rows it priced. The corpus loops, so the caller runs it again periodically.
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 PriceCandidates ¶ added in v0.33.0
func PriceCandidates(ctx context.Context, cands []PriceCandidate, store pricer) (int, error)
PriceCandidates prices the candidates the sample corpus says a person priced by hand, and returns how many it priced.
func RunPricing ¶ added in v0.33.0
func RunPricing(ctx context.Context, d *sql.DB, store pricer, every time.Duration, log func(msg string, args ...any))
RunPricing applies the sample user prices now and then every interval until ctx ends (replay backfill and corpus loops bring new sessions).
func Seed ¶
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 ¶
SeedCharges are the hand-written older sessions that complete the cost-source set (the replay stream supplies home_rate, network_estimate, the Rivian-billed DC fast and, via ApplySampleUserPrices, the user-priced hotel L2): 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.
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.
type PriceCandidate ¶ added in v0.33.0
PriceCandidate is a closed, unpriced demo charge.