Documentation
¶
Overview ¶
Package faction collects comprehensive faction data from a connected game client and persists it to the knowledge base for the faction dashboard.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector gathers faction data from a connected game client and persists it.
func NewCollector ¶
NewCollector returns a Collector that writes to kb.
func (*Collector) Collect ¶
func (c *Collector) Collect(ctx context.Context, client game.GameClient, includeFactionWide bool) error
Collect gathers faction data from the connected client's vantage point. When includeFactionWide is true, it also collects faction_info-derived data (header, members, relations, intel). Station-scoped data (facilities, storage, orders, missions, rooms, bases) is always collected for the current station and known bases. Best-effort: sub-query failures are logged, not fatal.
func (*Collector) CollectFaction ¶
func (c *Collector) CollectFaction(ctx context.Context, client game.GameClient, factionID string) error
CollectFaction fetches faction_info for an arbitrary factionID and persists its header, members, and relations (allies/enemies/wars). Unlike Collect it does not gather intel or station-scoped data (facilities/storage/orders/etc.) — those are only available from the agent's own faction/vantage. This is the path used to backfill details for factions we observe on other agents but are not a member of.
type FactionBackfiller ¶
type FactionBackfiller struct {
// contains filtered or unexported fields
}
FactionBackfiller fetches faction_info for observed faction_ids in the background and persists the details, so the factions tables fill in beyond the inline id+tag carried on sightings. Enqueue is called from the player observer (on the client's response goroutine) and must not block; the actual faction_info network calls happen on the backfiller's own goroutine.
func NewFactionBackfiller ¶
func NewFactionBackfiller(client game.GameClient, collector factionCollector, fresh factionFreshness, threshold time.Duration, logger *log.Logger) *FactionBackfiller
NewFactionBackfiller builds a backfiller. threshold is how long a stored faction is considered fresh before it's re-fetched.
func (*FactionBackfiller) Enqueue ¶
func (b *FactionBackfiller) Enqueue(ids ...string)
Enqueue schedules backfill for the given faction ids. Empty ids and ids already enqueued this session are dropped. Non-blocking: if the queue is full the id is skipped.
func (*FactionBackfiller) Start ¶
func (b *FactionBackfiller) Start(ctx context.Context)
Start launches the background worker until ctx is cancelled.
type Store ¶
type Store interface {
StoreFaction(ctx context.Context, r knowledge.FactionRecord) error
ReplaceFactionMembers(ctx context.Context, factionID string, members []knowledge.FactionMember) error
ReplaceFactionRelations(ctx context.Context, factionID string, rels []knowledge.FactionRelation) error
StoreFactionBase(ctx context.Context, b knowledge.FactionBaseRow) error
ReplaceFactionFacilities(ctx context.Context, factionID, baseID string, fs []knowledge.FactionFacilityRow) error
ReplaceFactionStorage(ctx context.Context, s knowledge.FactionStorageRow) error
ReplaceFactionOrders(ctx context.Context, factionID, baseID string, orders []knowledge.FactionOrderRow) error
ReplaceFactionMissions(ctx context.Context, factionID, baseID string, ms []knowledge.FactionMissionRow) error
ReplaceFactionRooms(ctx context.Context, factionID, baseID string, rooms []knowledge.FactionRoomRow) error
ReplaceFactionFuelBunkers(ctx context.Context, factionID string, bunkers []knowledge.FactionFuelBunkerRow) error
}
Store is the subset of *knowledge.SQLiteKB the Collector persists through. Satisfied by *knowledge.SQLiteKB.