PostReceive: Only run ProjectCacheWorker once per push
Every time we push something to the repository the PostReveive
service calls the GitPushService
and GitTagService
. When we have isolated commits this process works fine, but when we have large commits, that even can include tags, we enqueue some workers whose work is going to be thrown away (or not performing at all because of a lease token) because the next Git*Service
is going to create a similar worker.
This is the case of ProjectCacheWorker
. Every Git*Service
updates the statistics of the project but the next call to the worker will run again a new ProjectCacheWorker
. It's true that it has a lease time, but if the user pushes 1000 commits, we can avoid enqueuing and processing 999 workers.
I guess we can encapsulate this logic and only call the ProjectCacheWorker
once all the Git*Services
have been called.