OrchidSymbiont.TTLWrapper (orchid_symbiont v0.2.7)

Copy Markdown View Source

A GenServer wrapper that auto-terminates idle workers.

This wrapper monitors the wrapped worker and will automatically shut it down after a period of inactivity (TTL). Each request resets the idle timer.

Options

  • :name - The via-tuple name for registration (required)
  • :worker_mod - The module to start (required)
  • :worker_args - Arguments to pass to the worker's start_link (required)
  • :ttl - Idle timeout in milliseconds (default: :infinity)

How It Works

The wrapper starts the actual worker as a linked process. On each handle_call, the TTL timer is reset. If no requests are received within the TTL period, the worker is terminated.

The wrapper traps exits to properly handle worker crashes.

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts the TTL wrapper with the given options.

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()

Starts the TTL wrapper with the given options.