mirror of
https://github.com/IS1DI/x0gp.git
synced 2026-07-16 20:47:55 +00:00
35 lines
1.3 KiB
Go
35 lines
1.3 KiB
Go
package catalog
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// Store is the persistence layer used by Service. The runtime uses
|
|
// postgres.PgStore; tests use memoryStore (defined in catalog_test.go).
|
|
type Store interface {
|
|
// Load populates the in-memory cache at startup. Returns the full
|
|
// snapshot: tracks (with waypoints and tags) and cars.
|
|
Load(ctx context.Context) ([]TrackMeta, []CarMeta, error)
|
|
|
|
// UpsertTrack inserts or updates a track along with its waypoints and
|
|
// tags in a single transaction.
|
|
UpsertTrack(ctx context.Context, t TrackMeta) error
|
|
|
|
// DeleteTrack removes a track and all its waypoints / tags.
|
|
DeleteTrack(ctx context.Context, id string) error
|
|
|
|
// UpsertCar inserts or updates a car.
|
|
UpsertCar(ctx context.Context, c CarMeta) error
|
|
|
|
// DeleteCar removes a car by id.
|
|
DeleteCar(ctx context.Context, id string) error
|
|
|
|
// UpdateCarStats applies a partial mutation of read-mostly stats
|
|
// fields on a car. Used by the race engine hooks.
|
|
UpdateCarStats(ctx context.Context, id string, fn func(*CarMeta)) error
|
|
|
|
// Track Calendar methods
|
|
GetTrackCalendar(ctx context.Context) ([]TrackCalendarEntry, error)
|
|
CreateTrackCalendar(ctx context.Context, entry TrackCalendarEntry) (TrackCalendarEntry, error)
|
|
DeleteTrackCalendar(ctx context.Context, id int) error
|
|
} |