PhoenixKitAgent.Attachments.Slots (PhoenixKitAgent v0.1.0)

Copy Markdown View Source

The places for work on files on the node (spec §9): at most Bounds concurrent_jobs files are processed at the same time, of whom at most jobs_per_user are one user's. A file that finds no place waits for one, in turn, up to queue_wait_ms; with queued_jobs waiting already, or when the time is up, it is refused ({:error, :unavailable}) and the file failed as unavailable.

A place is held by the process that took it and is free when that process ends, however it ends; a waiting process that ends leaves the queue. The limits are read at each decision, so changing them needs no restart. Users are told apart by uuid only; nothing of a file is known here.

Summary

Functions

A place for the calling process, for user_uuid: :ok once there is one, {:error, :unavailable} when there is no room in the queue or the wait is over (or the slots are not running). The place is held until the caller ends.

Returns a specification to start this module under a supervisor.

Functions

acquire(user_uuid, server \\ __MODULE__)

@spec acquire(String.t(), GenServer.server()) :: :ok | {:error, :unavailable}

A place for the calling process, for user_uuid: :ok once there is one, {:error, :unavailable} when there is no room in the queue or the wait is over (or the slots are not running). The place is held until the caller ends.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.