Documentation
¶
Overview ¶
Package postgres implements the storage.Backend interface using GORM/PostgreSQL with internal queues and a background DB writer goroutine.
Index ¶
- type Backend
- func (b *Backend) AddMarker(m *core.Marker) (uint, error)
- func (b *Backend) AddSoldier(s *core.Soldier) error
- func (b *Backend) AddVehicle(v *core.Vehicle) error
- func (b *Backend) Close() error
- func (b *Backend) DeleteMarker(dm *core.DeleteMarker) error
- func (b *Backend) EndMission() error
- func (b *Backend) Init() error
- func (b *Backend) RecordAce3DeathEvent(e *core.Ace3DeathEvent) error
- func (b *Backend) RecordAce3UnconsciousEvent(e *core.Ace3UnconsciousEvent) error
- func (b *Backend) RecordChatEvent(e *core.ChatEvent) error
- func (b *Backend) RecordFiredEvent(e *core.FiredEvent) error
- func (b *Backend) RecordGeneralEvent(e *core.GeneralEvent) error
- func (b *Backend) RecordHitEvent(e *core.HitEvent) error
- func (b *Backend) RecordKillEvent(e *core.KillEvent) error
- func (b *Backend) RecordMarkerState(s *core.MarkerState) error
- func (b *Backend) RecordProjectileEvent(e *core.ProjectileEvent) error
- func (b *Backend) RecordRadioEvent(e *core.RadioEvent) error
- func (b *Backend) RecordSoldierState(s *core.SoldierState) error
- func (b *Backend) RecordTelemetryEvent(e *core.TelemetryEvent) error
- func (b *Backend) RecordTimeState(t *core.TimeState) error
- func (b *Backend) RecordVehicleState(v *core.VehicleState) error
- func (b *Backend) SetMissionID(id uint)
- func (b *Backend) StartMission(coreMission *core.Mission, coreWorld *core.World) error
- type Dependencies
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements storage.Backend using GORM/PostgreSQL with queue-based batch writes.
func (*Backend) AddMarker ¶
AddMarker inserts a marker synchronously (not queued) because markers are low-volume and need immediate ID assignment for the MarkerCache. Returns the DB-assigned ID (0 if no DB is configured).
func (*Backend) AddSoldier ¶
AddSoldier converts a core soldier to GORM and pushes to the write queue.
func (*Backend) AddVehicle ¶
AddVehicle converts a core vehicle to GORM and pushes to the write queue.
func (*Backend) DeleteMarker ¶
func (b *Backend) DeleteMarker(dm *core.DeleteMarker) error
DeleteMarker pushes an alpha=0 MarkerState to the queue and marks the marker as deleted in DB.
func (*Backend) EndMission ¶
EndMission is a no-op — mission lifecycle is managed by main.go.
func (*Backend) Init ¶
Init creates internal queues, runs schema migration, and starts the DB writer goroutine. If no DB was injected via Dependencies, it creates its own postgres connection.
func (*Backend) RecordAce3DeathEvent ¶
func (b *Backend) RecordAce3DeathEvent(e *core.Ace3DeathEvent) error
RecordAce3DeathEvent converts and queues an ACE3 death event.
func (*Backend) RecordAce3UnconsciousEvent ¶
func (b *Backend) RecordAce3UnconsciousEvent(e *core.Ace3UnconsciousEvent) error
RecordAce3UnconsciousEvent converts and queues an ACE3 unconscious event.
func (*Backend) RecordChatEvent ¶
RecordChatEvent converts and queues a chat event.
func (*Backend) RecordFiredEvent ¶
func (b *Backend) RecordFiredEvent(e *core.FiredEvent) error
RecordFiredEvent is a no-op — replaced by ProjectileEvent.
func (*Backend) RecordGeneralEvent ¶
func (b *Backend) RecordGeneralEvent(e *core.GeneralEvent) error
RecordGeneralEvent converts and queues a general event.
func (*Backend) RecordHitEvent ¶
RecordHitEvent is a no-op — replaced by ProjectileEvent.
func (*Backend) RecordKillEvent ¶
RecordKillEvent converts and queues a kill event.
func (*Backend) RecordMarkerState ¶
func (b *Backend) RecordMarkerState(s *core.MarkerState) error
RecordMarkerState converts and queues a marker state.
func (*Backend) RecordProjectileEvent ¶
func (b *Backend) RecordProjectileEvent(e *core.ProjectileEvent) error
RecordProjectileEvent converts and queues a projectile event.
func (*Backend) RecordRadioEvent ¶
func (b *Backend) RecordRadioEvent(e *core.RadioEvent) error
RecordRadioEvent converts and queues a radio event.
func (*Backend) RecordSoldierState ¶
func (b *Backend) RecordSoldierState(s *core.SoldierState) error
RecordSoldierState converts and queues a soldier state.
func (*Backend) RecordTelemetryEvent ¶
func (b *Backend) RecordTelemetryEvent(e *core.TelemetryEvent) error
RecordTelemetryEvent extracts FPS data and queues it for DB storage. Full telemetry data is not stored in the database.
func (*Backend) RecordTimeState ¶
RecordTimeState is a no-op — TimeState is not in DatabaseModels, only used by memory backend.
func (*Backend) RecordVehicleState ¶
func (b *Backend) RecordVehicleState(v *core.VehicleState) error
RecordVehicleState converts and queues a vehicle state.
func (*Backend) SetMissionID ¶
SetMissionID sets the current mission ID for the DB writer (used by CLI tools).
type Dependencies ¶
type Dependencies struct {
DB *gorm.DB
EntityCache *cache.EntityCache
MarkerCache *cache.MarkerCache
LogManager *logging.SlogManager
}
Dependencies holds all dependencies for the GORM storage backend.