Bedrock.JobQueue.Consumer (bedrock_job_queue v0.2.0)
View SourceConsumer supervision tree.
Supervises the Scanner, Manager, and Worker Pool for processing jobs, following the QuiCK paper's consumer architecture.
Architecture
Consumer (Supervisor)
├── Task.Supervisor (worker pool)
│ └── Task* (job execution tasks)
├── Manager (GenServer)
└── Scanner (GenServer)- Scanner: Continuously scans the pointer index for queues with visible items, also periodically garbage collects stale pointers
- Manager: Receives queue notifications, dequeues items, obtains leases, dispatches to workers
- Task.Supervisor: Dynamic pool of task workers up to concurrency limit
- Worker: Module providing job execution logic with timeout protection
Configuration
:repo- Required. The Bedrock Repo module:workers- Required. Map of topic strings to job modules:name- Process name (default:Bedrock.JobQueue.Consumer):root- Required. Root keyspace (from Directory):concurrency- Number of concurrent workers (default:System.schedulers_online()):batch_size- Items to dequeue per batch (default: 10):scan_interval- How often to scan for ready queues in ms (default: 100):backoff_fn- Retry backoff function (default:Bedrock.JobQueue.Config.default_backoff/1):gc_interval- How often to garbage collect stale pointers in ms (default: 60_000):gc_grace_period- Grace period before GC considers pointer stale in ms (default: 60_000)
Usage
{:ok, _pid} = Bedrock.JobQueue.Consumer.start_link(
repo: MyApp.Repo,
workers: %{"email:send" => MyApp.Jobs.SendEmail},
concurrency: 10
)
Summary
Functions
Returns a specification to start this module under a supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.