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 ¶
- Variables
- func AlwaysErrorHandler(payload any) error
- func BusyLoopHandler(payload interface{}) error
- func CounterHandler(payload interface{}) error
- func ExhaustRetriesHandler(payload any) error
- func FailThenSucceedHandler(payload any) error
- func FanoutHandler(payload interface{}) error
- func HelloHandler(payload interface{}) error
- func IntermittentHandler(payload any) error
- func LargePayloadHandler(payload interface{}) error
- func NestedHandler(payload interface{}) error
- func NewAlwaysErrorJob(msg string) (*api.Job, error)
- func NewBusyLoopJob(iterations int) (*api.Job, error)
- func NewCounterJob(n int) (*api.Job, error)
- func NewExhaustRetriesJob(id string) (*api.Job, error)
- func NewFailThenSucceedJob(id string, failTimes int) (*api.Job, error)
- func NewFanoutJob(workers, delayMs int) (*api.Job, error)
- func NewHelloJob(name string) (*api.Job, error)
- func NewIntermittentJob(id string, successProbability float64) (*api.Job, error)
- func NewLargePayloadJob(sizeBytes int) (*api.Job, error)
- func NewNestedPayloadJob() (*api.Job, error)
- func NewNilDerefJob() (*api.Job, error)
- func NewPanicJob(msg string) (*api.Job, error)
- func NewSleepJob(d time.Duration) (*api.Job, error)
- func NewSumJob(a, b int) (*api.Job, error)
- func NewUnicodeJob() (*api.Job, error)
- func NilDerefHandler(payload interface{}) error
- func PanicHandler(payload interface{}) error
- func RegisterAll(q *api.Queue) []error
- func SeedAll(queue QueueDispatcher) error
- func SleepHandler(payload interface{}) error
- func SumHandler(payload interface{}) error
- func UnicodeHandler(payload interface{}) error
- type AlwaysErrorPayload
- type BusyLoopPayload
- type CounterPayload
- type ExhaustRetriesPayload
- type FailThenSucceedPayload
- type FanoutPayload
- type HelloPayload
- type IntermittentPayload
- type LargePayload
- type NestedLevel1
- type NestedLevel2
- type NestedLevel3
- type NestedLevel4
- type NestedLevel5
- type NestedPayload
- type PanicPayload
- type QueueDispatcher
- type SleepPayload
- type StressConfig
- type StressMode
- type StressResult
- type SumPayload
- type UnicodePayload
Constants ¶
This section is empty.
Variables ¶
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 BusyLoopHandler ¶
func BusyLoopHandler(payload interface{}) error
func CounterHandler ¶
func CounterHandler(payload interface{}) error
func ExhaustRetriesHandler ¶
func FailThenSucceedHandler ¶
func FanoutHandler ¶
func FanoutHandler(payload interface{}) error
func HelloHandler ¶
func HelloHandler(payload interface{}) error
func IntermittentHandler ¶
func LargePayloadHandler ¶
func LargePayloadHandler(payload interface{}) error
func NestedHandler ¶
func NestedHandler(payload interface{}) error
func NewIntermittentJob ¶
func NewNestedPayloadJob ¶
func NewNilDerefJob ¶
func NewUnicodeJob ¶
func NilDerefHandler ¶
func NilDerefHandler(payload interface{}) error
func PanicHandler ¶
func PanicHandler(payload interface{}) error
func RegisterAll ¶
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 FanoutPayload ¶
type HelloPayload ¶
type HelloPayload struct {
Name string `json:"name"`
}
type IntermittentPayload ¶
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 ¶
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 ¶
func Stress(q QueueDispatcher, cfg StressConfig) (*StressResult, error)
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.