liveBook · Manning

Transient worker

As explained in Elixir in Action, Third Edition

A transient worker is a supervised worker process that is restarted only when it terminates abnormally.

A transient worker belongs in a supervision tree when normal termination is part of the expected workflow, but abnormal termination requires recovery. Configure it with restart: :transient in child_spec/1. section 9.1.6

One-off startup job

Run a one-off job, commonly powered by the Task module, under supervision. A normal completion leaves it stopped; a crash causes the supervisor to restart it. This preserves subtree management without restarting successful work. section 9.1.6

Choose the worker policy according to termination behavior:

  • Use :transient when normal completion is expected but abnormal termination should trigger a restart. section 9.1.6
  • Use :temporary when termination should never restart the process, such as a disconnected HTTP request or TCP connection. section 9.1.6
Figure 9.4 Supervision tree
CH09_F04_Juric3

Use the supervision tree diagram to place transient workers within the larger fault-isolation structure. section 9.1.6

How Elixir in Action, Third Edition covers it

How deep it goes
Defines restart behavior and child specification configuration, but does not descend into worker implementation internals.
Examples
Uses one-off startup jobs, HTTP request processes, and TCP connection processes to contrast restart policies.
What it assumes
Assumes familiarity with processes, supervision trees, child_spec/1, and normal versus abnormal termination.
What you can do after
Configure supervised workers to restart after abnormal termination while remaining stopped after normal completion.
How it connects
Connects transient workers to supervision trees, child specifications, Task, and supervisor restart strategies.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.