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

resources

command
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package main demonstrates resource-aware admission: one job definition whose memory requirement scales with its input, enqueued twice against a worker that cannot hold both at once.

This is the case that identical worker slots get wrong. "Concurrency 4" says a worker may run four jobs; it says nothing about how big they are. A render of a 2 MiB scene and a render of a 24 MiB scene are the same job to a slot-counting pool, so it starts both, and on a box sized for the small one the large one takes the whole machine down with it.

With a resource model the two are different sizes of the same work. The requirement is computed once, at enqueue, from the declared input; the worker admits against what is actually free; and the large render waits for room instead of being started next to work that is already using it.

Usage:

go run ./_examples/resources

Everything runs in-process: the memory store, the in-memory artifact backend Dispatch's own tests use, and a staging cache in a temp directory. No services to start, nothing to install.

Jump to

Keyboard shortcuts

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