ExAtlas.Orchestrator.ComputeServer (ExAtlas v0.5.0)

Copy Markdown View Source

One GenServer per tracked compute resource.

Responsibilities:

  • Hold the resource's normalized ExAtlas.Spec.Compute, its :user_id, :idle_ttl_ms, last-activity timestamp, and spawn opts.
  • Trap exits so terminate/2 always calls ExAtlas.terminate/2 on the upstream provider — even on supervisor shutdown or crash.
  • Drive its own idle reaper via the GenServer timeout: reply element: every message resets the timeout; hitting it stops the server normally and terminates the upstream resource.
  • Broadcast state changes over Phoenix.PubSub via ExAtlas.Orchestrator.Events.

Per project conventions, callback bodies never wrap logic in try/rescue — if a provider API raises, we let the server crash and the supervisor handles restart policy. The terminate/2 callback handles upstream teardown.

Summary

Functions

Returns a specification to start this module under a supervisor.

Return the current tracked state.

Bump last-activity so the idle reaper waits another idle_ttl_ms.

Types

state()

@type state() :: %{
  compute: ExAtlas.Spec.Compute.t(),
  opts: keyword(),
  idle_ttl_ms: pos_integer(),
  heartbeat_ms: pos_integer(),
  last_activity_ms: integer(),
  user_id: term() | nil
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

info(pid)

Return the current tracked state.

touch(pid)

Bump last-activity so the idle reaper waits another idle_ttl_ms.