Sprites.Session (Sprites v0.2.4)

Copy Markdown View Source

Session management for sprites.

Sessions represent active command executions that can be listed and attached to.

Summary

Functions

Represents an active execution session.

Creates a session from a map.

Returns how long ago the last activity was.

Returns true if the session has recent activity (within 5 minutes).

Lists all active sessions for a sprite.

Lists all active sessions for a sprite by name.

Types

t()

@type t() :: %Sprites.Session{
  bytes_per_second: float(),
  command: String.t(),
  created: DateTime.t() | nil,
  id: String.t(),
  is_active: boolean(),
  last_activity: DateTime.t() | nil,
  tty: boolean(),
  workdir: String.t() | nil
}

Functions

%Sprites.Session{}

(struct)

Represents an active execution session.

Fields

  • :id - Unique session identifier
  • :command - The command being executed
  • :workdir - Working directory
  • :created - When the session was created (DateTime)
  • :bytes_per_second - Throughput rate
  • :is_active - Whether the session is currently active
  • :last_activity - Time of last activity (DateTime)
  • :tty - Whether TTY is enabled

from_map(map)

@spec from_map(map()) :: t()

Creates a session from a map.

get_activity_age(session)

@spec get_activity_age(t()) :: integer()

Returns how long ago the last activity was.

is_session_active?(session)

@spec is_session_active?(t()) :: boolean()

Returns true if the session has recent activity (within 5 minutes).

list(sprite)

@spec list(Sprites.Sprite.t()) :: {:ok, [t()]} | {:error, term()}

Lists all active sessions for a sprite.

Examples

{:ok, sessions} = Sprites.Session.list(sprite)

list_by_name(client, name)

@spec list_by_name(Sprites.Client.t(), String.t()) :: {:ok, [t()]} | {:error, term()}

Lists all active sessions for a sprite by name.