Bedrock.JobQueue.Internal (bedrock_job_queue v0.2.0)
View SourceInternal implementation for JobQueue operations.
This module provides the backing implementation for functions defined by
use Bedrock.JobQueue. All functions accept a jobqueuemodule as the first
argument and use its `__config/0` to get repo, workers, etc.
While technically public, these functions are meant to be called through the generated JobQueue module rather than directly.
Summary
Functions
Enqueues a job for processing.
Initializes the root directory for the JobQueue module.
Returns the root keyspace for the given JobQueue module.
Gets queue statistics.
Functions
Enqueues a job for processing.
Options
:at- Schedule for a specific DateTime:in- Delay in milliseconds before processing:priority- Integer priority (lower = higher priority, default: 100):max_retries- Maximum retry attempts (default: 3):id- Custom job ID (default: auto-generated UUID)
Examples
# Immediate processing
enqueue(MyQueue, "tenant", "topic", payload)
# Schedule for specific time
enqueue(MyQueue, "tenant", "topic", payload, at: ~U[2024-01-15 10:00:00Z])
# Delay by duration
enqueue(MyQueue, "tenant", "topic", payload, in: :timer.hours(1))
# With priority
enqueue(MyQueue, "tenant", "topic", payload, priority: 0)
Initializes the root directory for the JobQueue module.
Creates or opens the directory and caches the resulting keyspace in persistent_term. Must be called within a transaction (or will create one).
Returns {:ok, keyspace} on success.
Returns the root keyspace for the given JobQueue module.
Reads from cache (populated by init_root/2 during startup). Falls back to creating a Keyspace from directory path if not cached.
Gets queue statistics.