ef-labs / stash-hook-mirror

An Atlassian Stash repository hook for mirroring to one or more remote git repositories.
MIT License
77 stars 58 forks source link

Replace ExecutorService with BucketedExecutor. #63

Closed bturner closed 5 years ago

bturner commented 6 years ago

Using the ScheduledExecutorService is better than performing the pushes directly in the hook method, but it still has limitations:

A better approach is to use the BucketedExecutor. It offers several improvements that are tailor-made for the work being done here:

This fixes issue #23 by ensuring at most a single push happens to any given mirror, and by allowing the overall concurrency, even in Data Center installations, to be controlled. (#34)

While I was making changes, because the minimum supported version for the plugin is already Bitbucket Server 5.5, I switched the code over to the new PostRepositoryHook SPI. This could be extended to allow the hook to respond to a wider array of events, so mirroring would be triggered after pull request merges, branch or tag creation, etc. However, for the sake of consistency, the current code still only triggers pushes after other pushes. (Related to #45)

Other things:

bturner commented 6 years ago

(Note: I'm the principal developer for Bitbucket Server. I'm submitting this in the hopes it will be useful, even if for nothing other than to be a basis for your own changes.)

This change is large, so you may or may not want to accept it. I've done some basic testing, of course, and everything works. More testing is almost certainly necessary. If you feel like the changes are worthwhile, though, I hope you can accept them.

adrianluisgonzalez commented 5 years ago

Thank you so much @bturner for all these changes! Sorry it took me 9 months...