worker

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: GPL-3.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalysisWorker

type AnalysisWorker struct {
	// contains filtered or unexported fields
}

AnalysisWorker polls for analysis jobs and processes them

func NewAnalysisWorker

func NewAnalysisWorker(cfg *WorkerConfig) *AnalysisWorker

NewAnalysisWorker creates a new worker

func (*AnalysisWorker) Run

func (w *AnalysisWorker) Run(ctx context.Context) error

Run starts the worker main loop

type Config

type Config struct {
	SimPlaysEarlyMid        int
	SimPliesEarlyMid        int
	SimStopEarlyMid         int
	SimPlaysEarlyPreendgame int
	SimPliesEarlyPreendgame int
	SimStopEarlyPreendgame  int
	PEGEarlyCutoff          bool
	Threads                 int
}

Config is analysis configuration from the server

type HeartbeatProgress

type HeartbeatProgress struct {
	// Current turn being analyzed (1-indexed)
	CurrentTurn int

	// Total number of turns to analyze
	TotalTurns int

	// Optional status message
	Status string
}

HeartbeatProgress represents progress information sent in heartbeats

type Job

type Job struct {
	// Unique identifier for this job
	JobID string

	// Game ID to analyze (e.g., "ABC123")
	GameID string

	// Analysis configuration
	Config *Config
}

Job represents an analysis job received from Woogles

type WooglesClient

type WooglesClient struct {
	// contains filtered or unexported fields
}

WooglesClient handles HTTP communication with the Woogles API

func NewWooglesClient

func NewWooglesClient(baseURL, apiKey string, cfg *config.Config, version string) *WooglesClient

NewWooglesClient creates a new Woogles API client

func (*WooglesClient) ClaimJob

func (c *WooglesClient) ClaimJob(ctx context.Context) (*Job, error)

ClaimJob attempts to claim a job from the queue Uses Connect RPC JSON format

func (*WooglesClient) FailJob added in v0.13.1

func (c *WooglesClient) FailJob(ctx context.Context, jobID, errorMessage string) error

FailJob reports a job as permanently failed to the server. Use this when a panic or unrecoverable error occurs processing a specific game so the job is not retried on other volunteers.

func (*WooglesClient) FetchGameHistory

func (c *WooglesClient) FetchGameHistory(ctx context.Context, gameID string) (*pb.GameHistory, error)

FetchGameHistory fetches the game history from Woogles

func (*WooglesClient) SendHeartbeat

func (c *WooglesClient) SendHeartbeat(ctx context.Context, jobID string, progress *HeartbeatProgress) error

SendHeartbeat sends a heartbeat to indicate the worker is still processing

func (*WooglesClient) SubmitResult

func (c *WooglesClient) SubmitResult(ctx context.Context, jobID string, resultJSON []byte) error

SubmitResult submits analysis results back to Woogles. resultJSON must be the protojson encoding of a macondo.GameAnalysisResult; it is embedded inline (not base64) so the server deserializes it as a typed proto.

type WorkerConfig

type WorkerConfig struct {
	// Base URL for the Woogles API (default: https://woogles.io)
	WooglesBaseURL string

	// Woogles API key for authentication
	APIKey string

	// How often to poll for new jobs when idle
	PollInterval time.Duration

	// How often to send heartbeats while processing
	HeartbeatInterval time.Duration

	// Macondo configuration for the analyzer
	MacondoConfig *config.Config

	// MacondoVersion is the build version of this worker binary (injected via ldflags)
	MacondoVersion string
}

WorkerConfig holds configuration for the analysis worker

func DefaultWorkerConfig

func DefaultWorkerConfig() *WorkerConfig

DefaultWorkerConfig creates a WorkerConfig with default values

Jump to

Keyboard shortcuts

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