liveBook · Manning

Temporary worker

As explained in Elixir in Action, Third Edition

A temporary worker is a supervised worker process that is not restarted after termination.

A temporary worker is a supervised process that is not restarted after termination. Configure it with restart: :temporary in child_spec/1 when restarting would serve no purpose. section 9.1.6

Use a temporary worker when:

  • A process handles an HTTP request or TCP connection and termination already closes the socket and disconnects the remote party. section 9.1.6
  • The process should remain in the supervision tree so the supervisor can terminate the subtree without leaving dangling processes. section 9.1.6

Connection handler

Define the connection-handling child with restart: :temporary. A failed handler is not replaced, while supervision still provides organized lifecycle control. section 9.1.6

Figure 9.4 Supervision tree
CH09_F04_Juric3

Locate the worker within the surrounding supervision tree and its lifecycle relationships. section 9.1.6

How Elixir in Action, Third Edition covers it

How deep it goes
Defines termination behavior and child_spec configuration, while contrasting transient workers without detailing implementation internals.
Examples
Uses HTTP request handlers and TCP connection processes as concrete examples.
What it assumes
Assumes familiarity with supervisors, supervision trees, child specifications, and process termination.
What you can do after
Operate/configure it by setting restart: :temporary in child_spec/1 for a supervised nonrestarting process.
How it connects
Connects supervision trees, supervisors, child specifications, and transient workers.

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.