Hyper.Node.Budget (Hyper v0.1.0)

Copy Markdown View Source

Public entry point for this node's resource budget. Thin facade over Hyper.Node.Budget.Hard, the per-node accounting GenServer supervised by Hyper.Node.Budget.Supervisor.

Summary

Functions

Authoritatively confirm this node can run spec, reserving its budget for the lifetime of owner. Live soft-load check first, then an atomic hard reserve.

Can this node run the given vm spec? :ok if yes, {:error, reason} otherwise.

Reserve the spec's budget, run callable, and release the budget afterwards.

Functions

admit(spec, owner)

@spec admit(Hyper.Vm.Instance.Spec.t(), pid()) :: :ok | {:error, term()}

Authoritatively confirm this node can run spec, reserving its budget for the lifetime of owner. Live soft-load check first, then an atomic hard reserve.

can_run(vm_spec)

@spec can_run(Hyper.Vm.Instance.Spec.t()) :: :ok | {:error, term()}

Can this node run the given vm spec? :ok if yes, {:error, reason} otherwise.

with_budget(vm_spec, callable)

@spec with_budget(Hyper.Vm.Instance.Spec.t(), (-> result)) ::
  result | {:error, term()}
when result: var

Reserve the spec's budget, run callable, and release the budget afterwards.