ObanSentinel.Guard (oban_sentinel v0.1.0)

Copy Markdown View Source

Worker execution guards for duration and process-memory limits.

use ObanSentinel.Guard generates perform/1 and expects the worker to implement perform_guarded/1. The protected work runs in a linked task so a timeout can be stopped without terminating Oban's executor process.

Summary

Functions

Injects an Oban perform/1 wrapper. Define perform_guarded/1 in the worker.

Runs a function in a supervised task with the supplied resource limits.

Types

limit_error()

@type limit_error() ::
  {:error, {:oban_sentinel, :duration_exceeded | :memory_exceeded}}

option()

@type option() ::
  {:max_duration, timeout() | :infinity}
  | {:max_memory, pos_integer() | :infinity}
  | {:max_memory_mb, pos_integer() | :infinity}

Functions

__using__(opts)

(macro)
@spec __using__(keyword()) :: Macro.t()

Injects an Oban perform/1 wrapper. Define perform_guarded/1 in the worker.

run(fun, opts)

@spec run((-> term()), [option()]) :: term() | limit_error()

Runs a function in a supervised task with the supplied resource limits.