Skip to content

How to guarantee only one job working at a time? #41

Answered by geofmureithi
makorne asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, You should be able to handle this with ConcurrencyLimitLayer for one job per worker or GlobalConcurrencyLimitLayer if you want only one job for all workers.
Just do:

.layer(ConcurrencyLimitLayer::new(1))
....

You can read more on the tower docs.
The reason you are experiencing this is that jobs are pulled by a thread pool under the hood. So a worker may be running multiple jobs at the same time. Tower has solutions for this.
Let me know this answers your question.

Replies: 8 comments 9 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by geofmureithi
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@geofmureithi
Comment options

Comment options

You must be logged in to vote
3 replies
@geofmureithi
Comment options

@makorne
Comment options

@geofmureithi
Comment options

Comment options

You must be logged in to vote
1 reply
@geofmureithi
Comment options

Comment options

You must be logged in to vote
1 reply
@geofmureithi
Comment options

Comment options

You must be logged in to vote
3 replies
@geofmureithi
Comment options

@makorne
Comment options

@geofmureithi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants