status

package
v0.1.74 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package status assembles the system status the front page shows.

It runs once a second, which is the constraint everything here is shaped by. The interesting numbers have wildly different costs — a Redis INFO is microseconds, a table-size query against a 600-million-row table is seconds — so they are gathered on separate schedules and cached between them. Fetching everything every tick would keep a database connection permanently busy answering a question nobody asked that second.

Index

Constants

View Source
const (
	QueueInterval            = 5 * time.Second
	SlowInterval             = 60 * time.Second
	CoverageInterval         = 15 * time.Minute
	KillmailCoverageInterval = 10 * time.Minute
)

How often each tier is refreshed. The tick is one second; everything else is served from the last value gathered.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector struct {
	Pool  *pgxpool.Pool
	Redis *redis.Client
	// contains filtered or unexported fields
}

Collector gathers status on tiered schedules.

Holds the cached slow values between ticks, so it is stateful and one instance must be reused across runs rather than built per tick — a fresh one would refetch everything every second, which is exactly what the tiering exists to avoid.

func NewCollector

func NewCollector(pool *pgxpool.Pool, sharedRedis *redis.Client) *Collector

NewCollector returns a collector that reports uptime from now.

func (*Collector) Collect

func (c *Collector) Collect(ctx context.Context) Status

Collect assembles the current status.

Every individual gatherer swallows its own failure and returns nil. A status page that shows nothing because one of eight sources is unwell is worse than one that shows seven sources and a gap — and this runs every second, so a transient failure resolves itself before anybody refreshes.

type CoverageAlliances

type CoverageAlliances struct {
	Active       int64 `json:"active"`
	CorpsActive  int64 `json:"corps_active"`
	CorpsCovered int64 `json:"corps_covered"`
}

type CoverageEntity

type CoverageEntity struct {
	Active  int64 `json:"active"`
	Covered int64 `json:"covered"`
}

type CoverageInfo

type CoverageInfo struct {
	WindowDays   int               `json:"window_days"`
	Characters   CoverageEntity    `json:"characters"`
	Corporations CoverageEntity    `json:"corporations"`
	Alliances    CoverageAlliances `json:"alliances"`
}

type DatabaseClusterInfo added in v0.1.23

type DatabaseClusterInfo struct {
	Replicas      int64   `json:"replicas"`
	Streaming     int64   `json:"streaming"`
	Synchronous   int64   `json:"synchronous"`
	MaxLagBytes   int64   `json:"max_lag_bytes"`
	MaxLagSeconds float64 `json:"max_lag_seconds"`
}

type DatabaseConnectionInfo added in v0.1.22

type DatabaseConnectionInfo struct {
	Total             int64 `json:"total"`
	Active            int64 `json:"active"`
	IdleInTransaction int64 `json:"idle_in_transaction"`
	Waiting           int64 `json:"waiting"`
	Max               int64 `json:"max"`
}

type DatabaseHistoryPoint added in v0.1.25

type DatabaseHistoryPoint struct {
	Timestamp             string  `json:"timestamp"`
	TransactionsPerSecond float64 `json:"transactions_per_second"`
	QueriesPerSecond      float64 `json:"queries_per_second"`
	AverageLatencyMS      float64 `json:"average_latency_ms"`
	ReadBytesPerSecond    float64 `json:"read_bytes_per_second"`
	WriteBytesPerSecond   float64 `json:"write_bytes_per_second"`
	WALBytesPerSecond     float64 `json:"wal_bytes_per_second"`
}

type DatabaseInfo

type DatabaseInfo struct {
	Size          string                       `json:"size"`
	Version       string                       `json:"version"`
	Role          string                       `json:"role"`
	SampledAt     string                       `json:"sampled_at"`
	UptimeSeconds int64                        `json:"uptime_seconds"`
	Connections   DatabaseConnectionInfo       `json:"connections"`
	Cluster       DatabaseClusterInfo          `json:"cluster"`
	Workload      *DatabaseWorkloadInfo        `json:"workload"`
	Statements    *DatabaseStatementInfo       `json:"statements"`
	Maintenance   *DatabaseMaintenanceInfo     `json:"maintenance"`
	History       []DatabaseHistoryPoint       `json:"history"`
	CacheHitRatio float64                      `json:"cache_hit_ratio"`
	WaitingLocks  int64                        `json:"waiting_locks"`
	Tables        map[string]DatabaseTableInfo `json:"tables"`
}

DatabaseInfo is the expensive tier: table sizes and row estimates.

type DatabaseMaintenanceInfo added in v0.1.25

type DatabaseMaintenanceInfo struct {
	Checkpoints             int64   `json:"checkpoints"`
	RequestedCheckpoints    int64   `json:"requested_checkpoints"`
	AverageCheckpointTimeMS float64 `json:"average_checkpoint_time_ms"`
	ActiveAutovacuums       int64   `json:"active_autovacuums"`
	DeadRows                int64   `json:"dead_rows"`
}

type DatabaseStatementInfo added in v0.1.23

type DatabaseStatementInfo struct {
	QueriesPerSecond float64 `json:"queries_per_second"`
	AverageLatencyMS float64 `json:"average_latency_ms"`
}

type DatabaseTableInfo

type DatabaseTableInfo struct {
	TotalSize string `json:"total_size"`
	DataSize  string `json:"data_size"`
	Rows      int64  `json:"rows"`
}

type DatabaseWorkloadInfo added in v0.1.23

type DatabaseWorkloadInfo struct {
	TransactionsPerSecond float64 `json:"transactions_per_second"`
	RollbackPercent       float64 `json:"rollback_percent"`
	WALBytesPerSecond     float64 `json:"wal_bytes_per_second"`
	ReadBytesPerSecond    float64 `json:"read_bytes_per_second"`
	WriteBytesPerSecond   float64 `json:"write_bytes_per_second"`
	ReadLatencyMS         float64 `json:"read_latency_ms"`
	WriteLatencyMS        float64 `json:"write_latency_ms"`
	RowsChangedPerSecond  float64 `json:"rows_changed_per_second"`
	TempBytesPerSecond    float64 `json:"temp_bytes_per_second"`
	Deadlocks             int64   `json:"deadlocks"`
}

type ESIFetchPeriod

type ESIFetchPeriod struct {
	Total          int64 `json:"total"`
	KillmailsFound int64 `json:"killmails_found"`
	NewKillmails   int64 `json:"new_killmails"`
	Failed         int64 `json:"failed"`
}

type ESIFetchSummary

type ESIFetchSummary struct {
	AllTime ESIFetchPeriod `json:"all_time"`
	Last24h ESIFetchPeriod `json:"last_24h"`
}

type ESIGroupInfo

type ESIGroupInfo struct {
	Remaining int64 `json:"remaining"`
	Limit     int64 `json:"limit"`
}

type ESIInfo

type ESIInfo struct {
	TQStatus    string                  `json:"tq_status"`
	TQPlayers   *int64                  `json:"tq_players"`
	ErrorBudget int64                   `json:"error_budget"`
	Paused      bool                    `json:"paused"`
	Groups      map[string]ESIGroupInfo `json:"groups"`
}

ESIInfo is the shared rate-limit and error budget.

type ESITokenInfo

type ESITokenInfo struct {
	Tokens  ESITokenSummary `json:"tokens"`
	Fetches ESIFetchSummary `json:"fetches"`
}

type ESITokenSummary

type ESITokenSummary struct {
	Total               int64 `json:"total"`
	Active              int64 `json:"active"`
	Revoked             int64 `json:"revoked"`
	CanFetchCharacter   int64 `json:"can_fetch_character"`
	CanFetchCorporation int64 `json:"can_fetch_corporation"`
}

type QueueInfo

type QueueInfo struct {
	Waiting int64 `json:"waiting"`
	Active  int64 `json:"active"`
	Delayed int64 `json:"delayed"`
	Failed  int64 `json:"failed"`
}

QueueInfo maps River states to the BullMQ-shaped contract the frontend consumes.

type RedisInfo

type RedisInfo struct {
	Version                string `json:"version"`
	UptimeSeconds          int64  `json:"uptime_seconds"`
	ConnectedClients       int64  `json:"connected_clients"`
	UsedMemory             string `json:"used_memory"`
	TotalCommandsProcessed int64  `json:"total_commands_processed"`
	KeyspaceHits           int64  `json:"keyspace_hits"`
	KeyspaceMisses         int64  `json:"keyspace_misses"`
}

RedisInfo is one instance's INFO.

type Status

type Status struct {
	Event     string `json:"event"`
	Uptime    int64  `json:"uptime"`
	StartedAt string `json:"started_at"`
	Timestamp string `json:"timestamp"`

	System    SystemInfo           `json:"system"`
	Database  *DatabaseInfo        `json:"database"`
	Queues    map[string]QueueInfo `json:"queues"`
	ESI       *ESIInfo             `json:"esi"`
	Redis     *RedisInfo           `json:"redis"`
	ZkbIngest *zkb.IngestStats     `json:"zkb_ingest"`
	Coverage  *CoverageInfo        `json:"coverage"`
	ESITokens *ESITokenInfo        `json:"esi_tokens"`
	Wallet    *WalletInfo          `json:"wallet"`

	// External HTTP-derived panels are intentionally deferred. Explicitly null
	// rather than absent, so the status page renders them as unknown.
	ImageServer any `json:"image_server"`
	WebSocket   any `json:"websocket"`
	Cloudflare  any `json:"cloudflare"`
}

Status is the published payload.

Optional sources are pointers left nil rather than omitted, so the shape stays stable and a consumer can tell "not collected" from "collected as zero".

type SystemInfo

type SystemInfo struct {
	Platform    string    `json:"platform"`
	Arch        string    `json:"arch"`
	CPUs        int       `json:"cpus"`
	MemoryTotal string    `json:"memory_total"`
	MemoryFree  string    `json:"memory_free"`
	LoadAverage []float64 `json:"load_average"`
}

SystemInfo describes the host.

type WalletInfo

type WalletInfo struct {
	TotalBalance string  `json:"total_balance"`
	UpdatedAt    *string `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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