Bedrock.JobQueue.Item (bedrock_job_queue v0.2.0)
View SourceA job item in the queue.
Fields
id- Unique job identifier (UUID binary)topic- Job type/topic (Phoenix PubSub-style, e.g., "user:created")priority- Integer priority (lower = higher priority)vesting_time- When the job becomes visible (milliseconds since epoch)lease_id- Current lease holder (nil if available)lease_expires_at- When the lease expireserror_count- Number of failed attemptsmax_retries- Maximum retry attemptspayload- Job-specific data (binary, typically JSON)queue_id- The queue/tenant this job belongs to
Summary
Functions
Returns true if retries are exhausted.
Builds the storage key tuple for this item.
Returns true if the job is currently leased.
Creates a new job item with defaults.
Returns true if the job is currently visible.
Types
@type t() :: %Bedrock.JobQueue.Item{ error_count: non_neg_integer(), id: binary(), lease_expires_at: non_neg_integer() | nil, lease_id: binary() | nil, max_retries: non_neg_integer(), payload: binary(), priority: non_neg_integer(), queue_id: String.t(), topic: String.t(), vesting_time: non_neg_integer() }
Functions
Returns true if retries are exhausted.
@spec key(t()) :: {non_neg_integer(), non_neg_integer(), binary()}
Builds the storage key tuple for this item.
Keys are {priority, vesting_time, id} which sorts items by priority first,
then by vesting time, then by unique id.
Returns true if the job is currently leased.
Options
:now- Current time in milliseconds (default: System.system_time(:millisecond))
Creates a new job item with defaults.
Options
:id- Custom job ID (default: random 16-byte binary):priority- Integer priority, lower = higher priority (default: 100):vesting_time- When the job becomes visible in ms since epoch (default: now):max_retries- Maximum retry attempts before dead-lettering (default: 3):now- Current time in ms, used for vesting_time default (default: System.system_time(:millisecond))
Priority Ordering
Jobs are processed in priority order where lower values = higher priority. For example, priority 0 is processed before priority 100. Use non-negative integers only; negative priorities are not supported.
@spec visible?(t(), non_neg_integer()) :: boolean()
Returns true if the job is currently visible.
An item is visible when its vesting time has passed and it is not actively leased. Expired leases are considered visible so another worker can reclaim stale work.