LightningWeb.WorkerPresence (Lightning v2.14.11-pre1)
View SourceHandles worker presence tracking for connected workers.
This module leverages Phoenix.Presence to track worker connections, allowing the system to dynamically calculate available worker capacity.
Summary
Functions
Callback implementation for Phoenix.Presence.fetch/2
.
Callback implementation for Phoenix.Presence.get_by_key/2
.
Callback implementation for Phoenix.Presence.list/1
.
Calculates the total worker capacity across all connected workers.
Callback implementation for Phoenix.Presence.track/3
.
Callback implementation for Phoenix.Presence.track/4
.
Tracks a worker's presence when they connect.
Callback implementation for Phoenix.Presence.untrack/2
.
Callback implementation for Phoenix.Presence.untrack/3
.
Callback implementation for Phoenix.Presence.update/3
.
Callback implementation for Phoenix.Presence.update/4
.
Functions
Callback implementation for Phoenix.Presence.fetch/2
.
Callback implementation for Phoenix.Presence.get_by_key/2
.
Callback implementation for Phoenix.Presence.list/1
.
Calculates the total worker capacity across all connected workers.
Returns the sum of all worker capacities currently tracked in Presence.
Examples
iex> LightningWeb.WorkerPresence.total_worker_capacity()
10
Callback implementation for Phoenix.Presence.track/3
.
Callback implementation for Phoenix.Presence.track/4
.
Tracks a worker's presence when they connect.
Parameters
pid
: The process identifier for the worker's channel.worker_id
: A unique identifier for the worker.capacity
: The number of concurrent runs this worker can handle.
Examples
iex> LightningWeb.WorkerPresence.track_worker(self(), "worker-123", 5)
{:ok, _ref}
Callback implementation for Phoenix.Presence.untrack/2
.
Callback implementation for Phoenix.Presence.untrack/3
.
Callback implementation for Phoenix.Presence.update/3
.
Callback implementation for Phoenix.Presence.update/4
.