Gamend.Accounts.StalePresenceSweeper (gamend_core v1.0.1296)

Copy Markdown View Source

Periodically sweeps users whose is_online flag is true but whose last_seen_at timestamp is older than a configurable threshold.

This is a safety net for node crashes or ungraceful disconnects where the UserChannel.terminate/2 callback never fires. Without this, users would remain marked as online indefinitely.

Configuration

interval_ms and stale_threshold_s are settings (GAMEND_PRESENCE_*). enabled: false in the app config turns the sweep off entirely (tests).

A connected socket refreshes last_seen_at on a heartbeat derived from the threshold (heartbeat_ms/0), so a live player is never swept.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the current configuration used by the sweeper.

How often a connected socket refreshes last_seen_at: three fifths of stale_threshold_s, so two refreshes fit before a user reads as stale, and never less often than every 3 minutes.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

config()

@spec config() :: keyword()

Returns the current configuration used by the sweeper.

heartbeat_ms()

@spec heartbeat_ms() :: pos_integer()

How often a connected socket refreshes last_seen_at: three fifths of stale_threshold_s, so two refreshes fit before a user reads as stale, and never less often than every 3 minutes.

start_link(opts \\ [])