workers

package
v0.1.71 Latest Latest
Warning

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

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

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

View Source
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 Describe

func Describe(registry *cron.Registry) string

Describe renders a one-line summary of what is and is not ported.

func ImplementedQueues

func ImplementedQueues() []string

ImplementedQueues returns the declared queues that have a worker.

func Register

func Register(d *Deps) (*river.Workers, *cron.Registry, error)

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

func RegisterCrons(d *Deps) (*cron.Registry, error)

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

type AllianceWorker

type AllianceWorker struct {
	river.WorkerDefaults[queue.AllianceArgs]
	Deps *Deps
}

AllianceWorker fetches one alliance.

func (*AllianceWorker) Work

type AnnouncementEventWorker

type AnnouncementEventWorker struct {
	river.WorkerDefaults[queue.AnnouncementEventArgs]
	Deps *Deps
}

AnnouncementEventWorker forwards announcement lifecycle events.

func (*AnnouncementEventWorker) Work

type BattleDetectionWorker

type BattleDetectionWorker struct {
	river.WorkerDefaults[queue.BattleDetectionArgs]
	Deps *Deps
}

BattleDetectionWorker finds the battles in one time window.

func (*BattleDetectionWorker) Work

type CampaignProcessingWorker

type CampaignProcessingWorker struct {
	river.WorkerDefaults[queue.CampaignProcessingArgs]
	Deps *Deps
}

CampaignProcessingWorker recomputes one campaign.

func (*CampaignProcessingWorker) Work

type CharacterHistoryWorker

type CharacterHistoryWorker struct {
	river.WorkerDefaults[queue.CharacterHistoryArgs]
	Deps *Deps
}

CharacterHistoryWorker fetches one character's corporation history.

func (*CharacterHistoryWorker) Work

type CharacterIntelRollupWorker added in v0.1.41

type CharacterIntelRollupWorker struct {
	river.WorkerDefaults[queue.CharacterIntelRollupArgs]
	Deps *Deps
}

func (*CharacterIntelRollupWorker) Work added in v0.1.41

type CharacterKillmailWorker

type CharacterKillmailWorker struct {
	river.WorkerDefaults[queue.CharacterKillmailArgs]
	Deps *Deps
}

CharacterKillmailWorker reads one character's killmails.

func (*CharacterKillmailWorker) Work

type CharacterWorker

type CharacterWorker struct {
	river.WorkerDefaults[queue.CharacterArgs]
	Deps *Deps
}

CharacterWorker fetches one character.

func (*CharacterWorker) Work

type CommentEventWorker

type CommentEventWorker struct {
	river.WorkerDefaults[queue.CommentEventArgs]
	Deps *Deps
}

CommentEventWorker forwards comment lifecycle events.

func (*CommentEventWorker) Work

type CorporationHistoryWorker

type CorporationHistoryWorker struct {
	river.WorkerDefaults[queue.CorporationHistoryArgs]
	Deps *Deps
}

CorporationHistoryWorker fetches one corporation's alliance history.

func (*CorporationHistoryWorker) Work

type CorporationKillmailWorker

type CorporationKillmailWorker struct {
	river.WorkerDefaults[queue.CorporationKillmailArgs]
	Deps *Deps
}

CorporationKillmailWorker reads one corporation's killmails.

func (*CorporationKillmailWorker) Work

type CorporationWalletWorker

type CorporationWalletWorker struct {
	river.WorkerDefaults[queue.CorporationWalletArgs]
	Deps *Deps
}

CorporationWalletWorker syncs one corporation's balances and journal.

func (*CorporationWalletWorker) Work

type CorporationWorker

type CorporationWorker struct {
	river.WorkerDefaults[queue.CorporationArgs]
	Deps *Deps
}

CorporationWorker fetches one corporation.

func (*CorporationWorker) Work

type Deps

type Deps struct {
	Pool  *pgxpool.Pool
	Redis *redis.Client

	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

type GraphIngestWorker

type GraphIngestWorker struct {
	river.WorkerDefaults[queue.GraphIngestArgs]
	Deps *Deps
}

GraphIngestWorker records one killmail's relationships.

func (*GraphIngestWorker) Work

type ImageRefreshWorker

type ImageRefreshWorker struct {
	river.WorkerDefaults[queue.ImageRefreshArgs]
	Deps *Deps
}

ImageRefreshWorker moves CCP refreshes off the HTTP request path. River's active-state uniqueness means a traffic spike can never multiply the origin request or write the same B2 pointer concurrently.

func (*ImageRefreshWorker) Work

type KillmailWorker

type KillmailWorker struct {
	river.WorkerDefaults[queue.KillmailArgs]
	Deps *Deps
}

KillmailWorker processes incoming killmails.

func (*KillmailWorker) Work

type StatsWriterWorker

type StatsWriterWorker struct {
	river.WorkerDefaults[queue.StatsWriterArgs]
	Deps *Deps
}

StatsWriterWorker folds one killmail into the aggregate counters.

func (*StatsWriterWorker) Work

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

type WarWorker

type WarWorker struct {
	river.WorkerDefaults[queue.WarArgs]
	Deps *Deps
}

WarWorker fetches one war's metadata, its allies, and the killmails fought under it.

func (*WarWorker) Work

func (w *WarWorker) Work(ctx context.Context, job *river.Job[queue.WarArgs]) error

Jump to

Keyboard shortcuts

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