journal

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	RaceID    int64
	CreatedAt time.Time
	UpdatedAt time.Time
	Notes     string
	Tags      []string
	Race      *store.DriverSession
}

Entry represents a journal entry with joined race context.

type FieldValidation

type FieldValidation struct {
	Field  string
	Code   string
	Params map[string]string
}

FieldValidation represents a validation failure for a specific field.

func ValidateTags

func ValidateTags(tags []string) []FieldValidation

ValidateTags checks that tags with known prefixes have valid values. Returns validation errors for any invalid tags.

type ListInput

type ListInput struct {
	DriverID int64
	From     time.Time
	To       time.Time
}

ListInput contains parameters for listing journal entries.

type MetricsEmitter

type MetricsEmitter interface {
	EmitCount(ctx context.Context, name string, count int) error
}

MetricsEmitter defines the metrics interface needed by the journal service.

type SaveInput

type SaveInput struct {
	DriverID int64
	RaceID   int64
	Notes    string
	Tags     []string
}

SaveInput contains the data needed to save a journal entry.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides business logic for race journal operations.

func NewService

func NewService(store Store, metrics MetricsEmitter) *Service

NewService creates a new journal service.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, driverID, raceID int64) error

Delete removes a journal entry. Idempotent - succeeds even if entry doesn't exist.

func (*Service) Get

func (s *Service) Get(ctx context.Context, driverID, raceID int64) (*Entry, error)

Get retrieves a single journal entry with its race context. Returns nil if the entry doesn't exist. Error is only for infrastructure failures.

func (*Service) List

func (s *Service) List(ctx context.Context, input ListInput) ([]Entry, error)

List retrieves journal entries within a time range, joined with race context.

func (*Service) Save

func (s *Service) Save(ctx context.Context, input SaveInput) (*Entry, error)

Save creates or updates a journal entry. Returns the saved entry with race context. Callers should validate input with ValidateTags and ValidateRaceExists before calling Save.

func (*Service) ValidateRaceExists

func (s *Service) ValidateRaceExists(ctx context.Context, driverID, raceID int64) (bool, error)

ValidateRaceExists checks if a race exists for the given driver. Returns true if the race exists, false if not. Error is only for infrastructure failures.

type Store

type Store interface {
	GetDriverSession(ctx context.Context, driverID int64, startTime time.Time) (*store.DriverSession, error)
	GetDriverSessions(ctx context.Context, driverID int64, startTimes []time.Time) ([]store.DriverSession, error)
	SaveJournalEntry(ctx context.Context, entry store.RaceJournalEntry) error
	GetJournalEntry(ctx context.Context, driverID, raceID int64) (*store.RaceJournalEntry, error)
	GetJournalEntries(ctx context.Context, driverID int64, from, to time.Time) ([]store.RaceJournalEntry, error)
	DeleteJournalEntry(ctx context.Context, driverID, raceID int64) error
}

Store defines the data access methods needed by the journal service.

Jump to

Keyboard shortcuts

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