ImagePipe.Transform.Detector.Warmup (image_pipe v0.5.0)

Copy Markdown View Source

One-shot worker that pre-loads a detector's models at boot.

An ImagePipe instance starts it with the instance's detector and the classes from its :detector_warmup option. A configuration used without an instance, such as a mount configured in the router, needs the worker in the host's supervision tree:

{ImagePipe.Transform.Detector.Warmup, detector: :default}

:detector accepts :default (the bundled adapter, used when omitted), nil (no work), or a custom detector module, matching the plug option.

A failed warmup, including one that raises or exits, is logged as a warning and retried, with exponential backoff capped at a minute, until it succeeds. A success after failures is logged at info level. After it succeeds, the worker exits normally, so restart: :transient does not restart it. Unavailable detectors are skipped, and so is a detector whose available?/1 raises, with a warning. It does not trap exits; shutdown during a download needs no cleanup.

Model loading runs in handle_continue/2, allowing start_link/1 to return without waiting for the download.

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()