benchjobs

package
v1.0.3-rc1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package jobs wires the test-job constructors (written by Wave 1 implementers #1-5) into a single one-shot dispatcher. SeedAll is invoked from main.go when the application is launched with the --seed-jobs CLI flag.

Index

Constants

This section is empty.

Variables

View Source
var AlwaysErrorAttempts atomic.Int64

AlwaysErrorAttempts counts every handler invocation across all AlwaysError jobs. Exported so stress runs can read the total at the end.

Functions

func AlwaysErrorHandler

func AlwaysErrorHandler(payload any) error

func BusyLoopHandler

func BusyLoopHandler(payload interface{}) error

func CounterHandler

func CounterHandler(payload interface{}) error

func ExhaustRetriesHandler

func ExhaustRetriesHandler(payload any) error

func FailThenSucceedHandler

func FailThenSucceedHandler(payload any) error

func FanoutHandler

func FanoutHandler(payload interface{}) error

func HelloHandler

func HelloHandler(payload interface{}) error

func IntermittentHandler

func IntermittentHandler(payload any) error

func LargePayloadHandler

func LargePayloadHandler(payload interface{}) error

func NestedHandler

func NestedHandler(payload interface{}) error

func NewAlwaysErrorJob

func NewAlwaysErrorJob(msg string) (*api.Job, error)

func NewBusyLoopJob

func NewBusyLoopJob(iterations int) (*api.Job, error)

func NewCounterJob

func NewCounterJob(n int) (*api.Job, error)

func NewExhaustRetriesJob

func NewExhaustRetriesJob(id string) (*api.Job, error)

func NewFailThenSucceedJob

func NewFailThenSucceedJob(id string, failTimes int) (*api.Job, error)

func NewFanoutJob

func NewFanoutJob(workers, delayMs int) (*api.Job, error)

func NewHelloJob

func NewHelloJob(name string) (*api.Job, error)

func NewIntermittentJob

func NewIntermittentJob(id string, successProbability float64) (*api.Job, error)

func NewLargePayloadJob

func NewLargePayloadJob(sizeBytes int) (*api.Job, error)

func NewNestedPayloadJob

func NewNestedPayloadJob() (*api.Job, error)

func NewNilDerefJob

func NewNilDerefJob() (*api.Job, error)

func NewPanicJob

func NewPanicJob(msg string) (*api.Job, error)

func NewSleepJob

func NewSleepJob(d time.Duration) (*api.Job, error)

func NewSumJob

func NewSumJob(a, b int) (*api.Job, error)

func NewUnicodeJob

func NewUnicodeJob() (*api.Job, error)

func NilDerefHandler

func NilDerefHandler(payload interface{}) error

func PanicHandler

func PanicHandler(payload interface{}) error

func RegisterAll

func RegisterAll(q *api.Queue) []error

RegisterAll wires every benchjob handler into the queue's in-process registry by the name each New*Job constructor uses. Returns collected errors so callers can log without aborting.

func SeedAll

func SeedAll(queue QueueDispatcher) error

SeedAll builds every Wave 1 test job via its constructor and dispatches it onto the supplied queue. Errors from constructors and from Dispatch are accumulated and returned joined so a single bad job does not hide the rest.

A 100ms sleep between dispatches keeps log output readable when the memory backend drains quickly.

func SleepHandler

func SleepHandler(payload interface{}) error

func SumHandler

func SumHandler(payload interface{}) error

func UnicodeHandler

func UnicodeHandler(payload interface{}) error

Types

type AlwaysErrorPayload

type AlwaysErrorPayload struct {
	Msg string `json:"msg"`
}

type BusyLoopPayload

type BusyLoopPayload struct {
	Iterations int `json:"iterations"`
}

type CounterPayload

type CounterPayload struct {
	N int `json:"n"`
}

type ExhaustRetriesPayload

type ExhaustRetriesPayload struct {
	ID string `json:"id"`
}

type FailThenSucceedPayload

type FailThenSucceedPayload struct {
	ID        string `json:"id"`
	FailTimes int    `json:"fail_times"`
}

type FanoutPayload

type FanoutPayload struct {
	Workers int `json:"workers"`
	DelayMs int `json:"delay_ms"`
}

type HelloPayload

type HelloPayload struct {
	Name string `json:"name"`
}

type IntermittentPayload

type IntermittentPayload struct {
	ID string  `json:"id"`
	P  float64 `json:"p"`
}

type LargePayload

type LargePayload struct {
	Data string `json:"data"`
}

type NestedLevel1

type NestedLevel1 struct {
	Level2    NestedLevel2 `json:"level2"`
	Timestamp time.Time    `json:"timestamp"`
	NullPtr   *int         `json:"null_ptr,omitempty"`
}

type NestedLevel2

type NestedLevel2 struct {
	Level3 NestedLevel3      `json:"level3"`
	Rows   []map[string]int  `json:"rows,omitempty"`
	IntMap map[string]string `json:"int_map,omitempty"` // JSON keys must be strings; callers stringify int keys
}

type NestedLevel3

type NestedLevel3 struct {
	Level4 NestedLevel4   `json:"level4"`
	Tags   []string       `json:"tags,omitempty"`
	Metric map[string]int `json:"metric,omitempty"`
}

type NestedLevel4

type NestedLevel4 struct {
	Level5 *NestedLevel5 `json:"level5,omitempty"`
}

type NestedLevel5

type NestedLevel5 struct {
	Leaf string `json:"leaf,omitempty"`
}

type NestedPayload

type NestedPayload struct {
	Level1 NestedLevel1 `json:"level1"`
}

type PanicPayload

type PanicPayload struct {
	Msg string `json:"msg"`
}

type QueueDispatcher

type QueueDispatcher interface {
	Dispatch(api.Job) (string, error)
}

QueueDispatcher is the minimum surface of *api.Queue that SeedAll needs. Declaring it here keeps jobs/registry.go testable with a fake dispatcher and free of a hard dependency on the concrete queue implementation.

type SleepPayload

type SleepPayload struct {
	Millis int64 `json:"millis"`
}

type StressConfig

type StressConfig struct {
	Count       int        // total jobs to dispatch
	Concurrency int        // dispatcher goroutines (upper bound on in-flight Dispatch calls)
	Mode        StressMode // job mix
}

StressConfig parameterises a stress run.

type StressMode

type StressMode string

StressMode controls which job mix the harness dispatches.

const (
	StressModeHello StressMode = "hello" // pure cheap work, measures dispatch throughput
	StressModeMixed StressMode = "mixed" // cheap + slow + fail + panic, measures backpressure
	StressModeFail  StressMode = "fail"  // retrying errors only, stresses re-enqueue path
)

type StressResult

type StressResult struct {
	Dispatched      int64
	DispatchErrors  int64
	ConstructErrors int64
	Elapsed         time.Duration
	StartGoroutines int
	PeakGoroutines  int
}

StressResult summarises a stress run.

func Stress

Stress dispatches Count jobs through Concurrency goroutines, waits for all dispatches to return (not for the workers to finish consuming), and returns timing + goroutine-pressure stats.

Note: on the memory backend, q.Jobs is unbuffered. Dispatcher goroutines above WorkerCount will block until a worker consumes. This is by design — dispatch throughput is gated by worker throughput.

type SumPayload

type SumPayload struct {
	A int `json:"a"`
	B int `json:"b"`
}

type UnicodePayload

type UnicodePayload struct {
	Text  string `json:"text"`
	Emoji string `json:"emoji"`
	Lang  string `json:"lang"`
}

Jump to

Keyboard shortcuts

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