Gamend.Async (gamend_core v1.0.1192)

Copy Markdown View Source

Utilities for running best-effort background work.

This is intentionally used for non-critical side effects (cache invalidation, notifications, hooks) where we want the caller to return quickly.

Tasks are started under a Task.Supervisor bounded by :max_children (see the host application supervision tree). When the supervisor is at capacity, the work runs inline in the caller instead of spawning an unsupervised process — under overload the system degrades to synchronous execution, which applies natural back-pressure instead of growing an unbounded process count. If the supervisor isn't running at all (e.g. certain test setups), we fall back to Task.start/1.

Telemetry: [:gamend, :async, :overload] is emitted each time a task is executed inline because the supervisor was full.

Summary

Types

zero_arity_fun()

@type zero_arity_fun() :: (-> any())

Functions

run(fun)

@spec run(zero_arity_fun()) :: :ok