Module

tuck/limits

src/tuck/limits.pooka

Put expensive rendering in its own room. Budgets cover source size, final output size, BEAM work, worker heap, and elapsed time. Cancellation joins the worker before returning, so a timed-out filter cannot keep running.

API reference

class

Budget

src/tuck/limits.pooka:12
class Budget(
  max_source_bytes: Int,
  max_output_bytes: Int,
  max_reductions: Int,
  max_heap_words: Int,
  timeout_ms: Int
)

Byte limits describe UTF-8. Heap limits use BEAM words. Work is measured in reductions, so deeply nested templates do not need a guessed nesting cost.

field

max_source_bytes

src/tuck/limits.pooka:13
max_source_bytes: Int
INFERREDInt
field

max_output_bytes

src/tuck/limits.pooka:14
max_output_bytes: Int
INFERREDInt
field

max_reductions

src/tuck/limits.pooka:15
max_reductions: Int
INFERREDInt
field

max_heap_words

src/tuck/limits.pooka:16
max_heap_words: Int
INFERREDInt
field

timeout_ms

src/tuck/limits.pooka:17
timeout_ms: Int
INFERREDInt
constructor

new

src/tuck/limits.pooka:13
INFERREDfn(Int, Int, Int, Int, Int) -> tuck/limits.Budget
function

defaults

src/tuck/limits.pooka:33
defaults() -> Budget
INFERREDfn() -> tuck/limits.Budget

One MiB of source, four MiB of output, twenty million reductions, four million heap words, and five seconds.

Pooka
assert limits.defaults().max_source_bytes == 1048576
function

run

src/tuck/limits.pooka:39
run(source: String, budget: Budget, work: fn() -> a) -> Result(a, String)
INFERREDfn(String, tuck/limits.Budget, fn() -> a) -> Result(a, String)

Run a typed operation in a bounded worker. The callback's value is returned unchanged; only resource failures acquire an explanatory message.

function

output

src/tuck/limits.pooka:64
output(value: String, budget: Budget) -> Result(String, String)
INFERREDfn(String, tuck/limits.Budget) -> Result(String, String)

Check the completed output inside its worker, before sending it to the caller. Interim allocations are covered by the worker's heap/work budgets.