Help us shape the future of Go! Take the 2026 Go Developer Survey

server

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAssignTrigger int32 = 500 // 5 sec

Variables

This section is empty.

Functions

func CheckPassword

func CheckPassword(plaintext, hashed string) bool

func FetchWorkersForWatchdog

func FetchWorkersForWatchdog(ctx context.Context, db *sql.DB) ([]watchdog.WorkerInfo, error)

FetchWorkersForWatchdog reads workers and builds WorkerInfo list

func HttpServer

func HttpServer(cfg config.Config) (tls.Certificate, string, http.Handler, error)

func IsAdmin

func IsAdmin(ctx context.Context) bool

func LoadEmbeddedCertificates

func LoadEmbeddedCertificates() (tls.Certificate, string, error)

func LogoutHandler

func LogoutHandler(w http.ResponseWriter, r *http.Request)

LogoutHandler clears the session_token cookie to log out the user.

func NewLogin

func NewLogin(s *taskQueueServer) http.HandlerFunc

NewLogin returns an HTTP handler function to process login requests.

func Serve

func Serve(cfg config.Config, ctx context.Context, cancel context.CancelFunc) error

Types

type Accumulator

type Accumulator struct {
	Count int32
	Sum   float64
	Min   float64
	Max   float64
}

In-memory aggregation types for step/workflow stats Accumulator holds aggregation stats for durations/counts.

type AuthenticatedUser

type AuthenticatedUser struct {
	UserID   int
	Username string
	IsAdmin  bool
}

func GetUserFromContext

func GetUserFromContext(ctx context.Context) *AuthenticatedUser

type Job

type Job struct {
	JobID         int32
	WorkerID      int32
	WorkerName    string
	ProviderID    int32
	ProviderName  string
	Region        string
	Flavor        string
	Action        rune // "C", "D", "R"
	Retry         int
	Timeout       time.Duration
	FromRecruiter bool
}

Job represents a task to be executed.

type ParamSpec

type ParamSpec struct {
	Name     string   `json:"name"`
	Type     string   `json:"type"`
	Required bool     `json:"required"`
	Default  string   `json:"default"`
	Help     string   `json:"help"` // Or `json:"description"` if your field is named so
	Choices  []string `json:"choices,omitempty"`
}

type QualityDefinition added in v0.7.2

type QualityDefinition struct {
	Variables map[string]string `json:"variables"` // name -> regex pattern (one capture group)
	Formula   string            `json:"formula"`   // arithmetic expression over variable names
}

QualityDefinition is the JSON structure stored in step.quality_definition.

func ParseQualityDefinition added in v0.7.2

func ParseQualityDefinition(jsonStr string) (*QualityDefinition, error)

ParseQualityDefinition parses a JSON quality definition string.

type QualityResult added in v0.7.2

type QualityResult struct {
	Vars  map[string]float64 `json:"vars"`
	Score float64            `json:"score"`
}

QualityResult holds extracted variables and computed score.

func ExtractQuality added in v0.7.2

func ExtractQuality(def *QualityDefinition, stdout, stderr string) (*QualityResult, error)

ExtractQuality runs quality variable regexes against log text and evaluates the formula. Each regex captures the LAST match (for iterative programs that output metrics repeatedly).

type StepAgg

type StepAgg struct {
	// Task status counters
	Waiting      int32
	Pending      int32
	Accepted     int32
	Running      int32
	Uploading    int32
	Succeeded    int32
	Failed       int32
	ReallyFailed int32          // tasks that have exhausted all retries and are failed
	Retrying     int32          // tasks currently being retried
	RetryingSet  map[int32]bool // set of task IDs currently retrying
	Total        int32

	// Accumulators for durations
	Download   Accumulator
	Upload     Accumulator
	SuccessRun Accumulator
	FailRun    Accumulator

	// RunningTasks maps taskID to start time
	RunningTasks map[int32]time.Time

	// Time bounds (epoch seconds)
	StartTime *int64
	EndTime   *int64
}

StepAgg aggregates statistics for a step within a workflow.

func NewStepAgg

func NewStepAgg() *StepAgg

NewStepAgg creates a new StepAgg with sensible defaults.

type StepStatsAgg

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

StepStatsAgg holds in-memory aggregated statistics for steps in workflows.

func NewStepStatsAgg

func NewStepStatsAgg(db *sql.DB) (*StepStatsAgg, error)

NewStepStatsAgg creates a new StepStatsAgg with initialized internal maps.

func (*StepStatsAgg) EnsureStep

func (a *StepStatsAgg) EnsureStep(workflowID, stepID int32)

EnsureStep guarantees an entry exists for (workflowID, stepID).

func (*StepStatsAgg) Reconcile added in v0.7.2

func (a *StepStatsAgg) Reconcile(db *sql.DB)

Reconcile rebuilds the in-memory stats from the database, fixing any drift between cached counters and actual task states.

func (*StepStatsAgg) RemoveStep

func (a *StepStatsAgg) RemoveStep(stepID int32) int32

RemoveStep deletes a step entry by its stepID, scanning all workflows to locate it.

func (*StepStatsAgg) RemoveWorkflow

func (a *StepStatsAgg) RemoveWorkflow(workflowID int32)

type TaskUpdateBroadcast

type TaskUpdateBroadcast struct {
	TaskId   int32
	Status   string
	WorkerId int32
}

Jump to

Keyboard shortcuts

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