Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
add semaphore todo
Browse files Browse the repository at this point in the history
  • Loading branch information
bretthoerner committed Feb 5, 2024
1 parent c0d8ba2 commit 16b67a7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hook-worker/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ impl<'p> WebhookWorker<'p> {
if transactional {
loop {
report_semaphore_utilization();
// TODO: We could grab semaphore permits here using something like:
// `min(semaphore.available_permits(), dequeue_batch_size)`
// And then dequeue only up to that many jobs. We'd then need to hand back the
// difference in permits based on how many jobs were dequeued.
let mut batch = self.wait_for_jobs_tx().await;
dequeue_batch_size_histogram.record(batch.jobs.len() as f64);

Expand Down Expand Up @@ -228,6 +232,10 @@ impl<'p> WebhookWorker<'p> {
} else {
loop {
report_semaphore_utilization();
// TODO: We could grab semaphore permits here using something like:
// `min(semaphore.available_permits(), dequeue_batch_size)`
// And then dequeue only up to that many jobs. We'd then need to hand back the
// difference in permits based on how many jobs were dequeued.
let batch = self.wait_for_jobs().await;
dequeue_batch_size_histogram.record(batch.jobs.len() as f64);

Expand Down

0 comments on commit 16b67a7

Please sign in to comment.