Documentation
¶
Overview ¶
Package workers is where the job implementations live and where everything else is wired together.
It sits at the top of the dependency graph on purpose. The queue knows how to enqueue and the entity, killmail and importer packages know how to do the work, but none of them know about each other — entities returns the follow-up work a refresh implies rather than enqueuing it, and killmail parses rather than dispatching. Joining them is this package's only job, which keeps the cycle that would otherwise form (queue → entities → queue) from existing.
Index ¶
- Constants
- func ConsumableQueues() []string
- func CronQueues() []string
- func Describe(registry *cron.Registry) string
- func ImplementedQueues() []string
- func Register(d *Deps) (*river.Workers, *cron.Registry, error)
- func RegisterCrons(d *Deps) (*cron.Registry, error)
- func UnimplementedQueues() []string
- type AchievementsWorker
- type AllianceWorker
- type AnnouncementEventWorker
- type BattleDetectionWorker
- type CampaignProcessingWorker
- type CharacterHistoryWorker
- type CharacterIntelRollupWorker
- type CharacterKillmailWorker
- type CharacterWorker
- type CommentEventWorker
- type CorporationHistoryWorker
- type CorporationKillmailWorker
- type CorporationWalletWorker
- type CorporationWorker
- type Deps
- type FitExtractWorker
- type FitStatsWorker
- type GraphIngestWorker
- type KillmailWorker
- type StatsWriterWorker
- type TokenRefreshWorker
- type WarWorker
Constants ¶
const WarTickerMaxAge = 24 * time.Hour
WarTickerMaxAge bounds how stale a transition may be and still be announced.
The repair sweep walks hundreds of thousands of finished wars. Without a bound, the first pass over that backlog would announce every war EVE has ever had, in the order it happened to read them.
Variables ¶
This section is empty.
Functions ¶
func ConsumableQueues ¶
func ConsumableQueues() []string
ConsumableQueues returns the queues a worker process should consume.
The cron queue is deliberately not among them: scheduled jobs run on the cron process, which both schedules and works them. Keeping them off the general workers is the whole reason the cron queue is separate — a nightly rebuild that runs for twenty minutes must not occupy a slot that killmails need.
Consuming a declared-but-unported queue would be worse than not consuming it. River fetches the job, finds no worker for the kind, and the job fails — so the backlog would drain into the failure table instead of waiting for the port to land.
func CronQueues ¶
func CronQueues() []string
CronQueues is what the cron process consumes.
River will not start a client that has periodic jobs but nothing to work, and that restriction is right: a process that only inserted rows and relied on something else to run them would report itself healthy while nothing scheduled ever happened.
func ImplementedQueues ¶
func ImplementedQueues() []string
ImplementedQueues returns the declared queues that have a worker.
func Register ¶
Register builds the worker set.
The returned registry is the cron dispatch table; the workers themselves go into River. Both are needed by a process that consumes jobs, and neither by one that only enqueues.
func RegisterCrons ¶
RegisterCrons builds the cron registry for the given dependencies.
func UnimplementedQueues ¶
func UnimplementedQueues() []string
UnimplementedQueues returns the declared queues with no Go worker.
Reported rather than hidden. A worker process that consumes twenty queues and implements six looks, from the outside, exactly like one that implements all twenty and finds nothing to do — right up until someone notices weeks later that no achievements have been awarded since the cutover.
Types ¶
type AchievementsWorker ¶
type AchievementsWorker struct {
river.WorkerDefaults[queue.AchievementsArgs]
Deps *Deps
}
AchievementsWorker awards the badges one killmail earned.
The job carries the killmail's shape rather than its id, unlike stats_writer. That is the TypeScript's choice and it is kept: the fields needed are a small fixed set already in hand when the killmail is processed, and re-reading the mail and its attackers would be two queries to reconstruct what the caller just had.
func (*AchievementsWorker) Work ¶
func (w *AchievementsWorker) Work(ctx context.Context, job *river.Job[queue.AchievementsArgs]) error
type AllianceWorker ¶
type AllianceWorker struct {
river.WorkerDefaults[queue.AllianceArgs]
Deps *Deps
}
AllianceWorker fetches one alliance.
func (*AllianceWorker) Work ¶
func (w *AllianceWorker) Work(ctx context.Context, job *river.Job[queue.AllianceArgs]) error
type AnnouncementEventWorker ¶
type AnnouncementEventWorker struct {
river.WorkerDefaults[queue.AnnouncementEventArgs]
Deps *Deps
}
AnnouncementEventWorker forwards announcement lifecycle events.
func (*AnnouncementEventWorker) Work ¶
func (w *AnnouncementEventWorker) Work(ctx context.Context, job *river.Job[queue.AnnouncementEventArgs]) error
type BattleDetectionWorker ¶
type BattleDetectionWorker struct {
river.WorkerDefaults[queue.BattleDetectionArgs]
Deps *Deps
}
BattleDetectionWorker finds the battles in one time window.
func (*BattleDetectionWorker) Work ¶
func (w *BattleDetectionWorker) Work(ctx context.Context, job *river.Job[queue.BattleDetectionArgs]) error
type CampaignProcessingWorker ¶
type CampaignProcessingWorker struct {
river.WorkerDefaults[queue.CampaignProcessingArgs]
Deps *Deps
}
CampaignProcessingWorker recomputes one campaign.
func (*CampaignProcessingWorker) Work ¶
func (w *CampaignProcessingWorker) Work(ctx context.Context, job *river.Job[queue.CampaignProcessingArgs]) error
type CharacterHistoryWorker ¶
type CharacterHistoryWorker struct {
river.WorkerDefaults[queue.CharacterHistoryArgs]
Deps *Deps
}
CharacterHistoryWorker fetches one character's corporation history.
func (*CharacterHistoryWorker) Work ¶
func (w *CharacterHistoryWorker) Work(ctx context.Context, job *river.Job[queue.CharacterHistoryArgs]) error
type CharacterIntelRollupWorker ¶ added in v0.1.41
type CharacterIntelRollupWorker struct {
river.WorkerDefaults[queue.CharacterIntelRollupArgs]
Deps *Deps
}
func (*CharacterIntelRollupWorker) Work ¶ added in v0.1.41
func (w *CharacterIntelRollupWorker) Work(ctx context.Context, job *river.Job[queue.CharacterIntelRollupArgs]) error
type CharacterKillmailWorker ¶
type CharacterKillmailWorker struct {
river.WorkerDefaults[queue.CharacterKillmailArgs]
Deps *Deps
}
CharacterKillmailWorker reads one character's killmails.
func (*CharacterKillmailWorker) Work ¶
func (w *CharacterKillmailWorker) Work(ctx context.Context, job *river.Job[queue.CharacterKillmailArgs]) error
type CharacterWorker ¶
type CharacterWorker struct {
river.WorkerDefaults[queue.CharacterArgs]
Deps *Deps
}
CharacterWorker fetches one character.
func (*CharacterWorker) Work ¶
func (w *CharacterWorker) Work(ctx context.Context, job *river.Job[queue.CharacterArgs]) error
type CommentEventWorker ¶
type CommentEventWorker struct {
river.WorkerDefaults[queue.CommentEventArgs]
Deps *Deps
}
CommentEventWorker forwards comment lifecycle events.
func (*CommentEventWorker) Work ¶
func (w *CommentEventWorker) Work(ctx context.Context, job *river.Job[queue.CommentEventArgs]) error
type CorporationHistoryWorker ¶
type CorporationHistoryWorker struct {
river.WorkerDefaults[queue.CorporationHistoryArgs]
Deps *Deps
}
CorporationHistoryWorker fetches one corporation's alliance history.
func (*CorporationHistoryWorker) Work ¶
func (w *CorporationHistoryWorker) Work(ctx context.Context, job *river.Job[queue.CorporationHistoryArgs]) error
type CorporationKillmailWorker ¶
type CorporationKillmailWorker struct {
river.WorkerDefaults[queue.CorporationKillmailArgs]
Deps *Deps
}
CorporationKillmailWorker reads one corporation's killmails.
func (*CorporationKillmailWorker) Work ¶
func (w *CorporationKillmailWorker) Work(ctx context.Context, job *river.Job[queue.CorporationKillmailArgs]) error
type CorporationWalletWorker ¶
type CorporationWalletWorker struct {
river.WorkerDefaults[queue.CorporationWalletArgs]
Deps *Deps
}
CorporationWalletWorker syncs one corporation's balances and journal.
func (*CorporationWalletWorker) Work ¶
func (w *CorporationWalletWorker) Work(ctx context.Context, job *river.Job[queue.CorporationWalletArgs]) error
type CorporationWorker ¶
type CorporationWorker struct {
river.WorkerDefaults[queue.CorporationArgs]
Deps *Deps
}
CorporationWorker fetches one corporation.
func (*CorporationWorker) Work ¶
func (w *CorporationWorker) Work(ctx context.Context, job *river.Job[queue.CorporationArgs]) error
type Deps ¶
type Deps struct {
Pool *pgxpool.Pool
Redis *redis.Client
// DataDir is the configured writable state directory for import caches.
DataDir string
ESI *esi.Client
SSO *sso.Client
// Graph is the Memgraph client. Nil when Memgraph is unreachable or not
// configured — the graph is entirely derived, so running without it is a
// degraded mode rather than a failure.
Graph *graph.Client
EveRef *everef.Client
ZKB *zkb.Client
// MarketPaths resolves a hull to its /market/... link for killlist rows.
// Materialised once with the cache, for the same reason: it is a thousand
// SDE rows that never change while the process is running.
MarketPaths eve.MarketPaths
// Relay publishes live events. Nil in CLI paths that run a job once, so
// every use has to tolerate that — Publisher's methods are nil-safe.
Relay *relay.Publisher
// Ticker emits the ephemeral site announcements. Like Relay it is nil-safe
// and is genuinely nil in one-shot CLI paths: detecting a battle from the
// command line should not require a relay to announce it to.
Ticker *ticker.Emitter
// Cache and Prices are the static-data snapshot and the price resolver.
// Both are loaded once at startup: the cache because it is immutable after
// load, and Prices because it memoises per day and a worker sharing one
// resolver across a thousand killmails does a fraction of the queries a
// per-job one would.
Cache *eve.Cache
Prices *eve.Prices
// Queue is how a job enqueues follow-up work. Nil in the CLI paths that run
// a job once without a running queue, so every use has to tolerate that.
Queue *queue.Client
// Images serves and refreshes entity images. ImageStore is kept separately
// for the daily bulk TurtleTools import, which does not belong in the HTTP
// service's response cache.
Images *images.Service
ImageStore images.ObjectStore
GitHubToken string
// UserAgent identifies us to CCP, which their acceptable-use policy requires.
UserAgent string
Log zerolog.Logger
// contains filtered or unexported fields
}
Deps is everything the jobs need.
Passed as one struct rather than as arguments because almost every job needs most of it, and because a worker that needs something not listed here is a worker whose dependency was never wired — a compile error rather than a nil pointer at three in the morning.
type FitExtractWorker ¶
type FitExtractWorker struct {
river.WorkerDefaults[queue.FitExtractArgs]
Deps *Deps
}
FitExtractWorker records the fit a victim was flying.
func (*FitExtractWorker) Work ¶
func (w *FitExtractWorker) Work(ctx context.Context, job *river.Job[queue.FitExtractArgs]) error
type FitStatsWorker ¶ added in v0.1.78
type FitStatsWorker struct {
river.WorkerDefaults[queue.FitStatsArgs]
Deps *Deps
}
func (*FitStatsWorker) Work ¶ added in v0.1.78
func (w *FitStatsWorker) Work(ctx context.Context, job *river.Job[queue.FitStatsArgs]) error
type GraphIngestWorker ¶
type GraphIngestWorker struct {
river.WorkerDefaults[queue.GraphIngestArgs]
Deps *Deps
}
GraphIngestWorker records one killmail's relationships.
func (*GraphIngestWorker) Work ¶
func (w *GraphIngestWorker) Work(ctx context.Context, job *river.Job[queue.GraphIngestArgs]) error
type KillmailWorker ¶
type KillmailWorker struct {
river.WorkerDefaults[queue.KillmailArgs]
Deps *Deps
}
KillmailWorker processes incoming killmails.
func (*KillmailWorker) Work ¶
func (w *KillmailWorker) Work(ctx context.Context, job *river.Job[queue.KillmailArgs]) error
type StatsWriterWorker ¶
type StatsWriterWorker struct {
river.WorkerDefaults[queue.StatsWriterArgs]
Deps *Deps
}
StatsWriterWorker folds one killmail into the aggregate counters.
func (*StatsWriterWorker) Work ¶
func (w *StatsWriterWorker) Work(ctx context.Context, job *river.Job[queue.StatsWriterArgs]) error
type TokenRefreshWorker ¶
type TokenRefreshWorker struct {
river.WorkerDefaults[queue.TokenRefreshArgs]
Deps *Deps
}
TokenRefreshWorker refreshes one character's SSO token and dispatches the work its scopes permit.
The dispatch is here rather than on a schedule because the scopes are only known after the refresh: SSO decides what the token can do, and that can change between one refresh and the next when a user re-consents or loses an in-game role.
func (*TokenRefreshWorker) Work ¶
func (w *TokenRefreshWorker) Work(ctx context.Context, job *river.Job[queue.TokenRefreshArgs]) error