eiffel-community / eiffel-gerrit-plugin

Eiffel Gerrit plugin listens on the changes in Gerrit and sends out Eiffel events
Apache License 2.0
3 stars 15 forks source link

Send calls are now threaded #38

Closed Christoffer-Cortes closed 4 years ago

Christoffer-Cortes commented 4 years ago

Applicable Issues

Closes https://github.com/eiffel-community/eiffel-gerrit-plugin/issues/36

Description of the Change

Added a ThreadPoolExecutor that takes care of send calls.

Alternate Designs

There are other alternative implementations in for example the rabbitmq plugin for gerrit and in some internal code.

Benefits

EventListener threads are no longer held.

Possible Drawbacks

The queue is set to have 3 workers at the moment and a queue of an arbitrary length. I guess this could lead to our plugin taking up more memory.

Sign-off

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or

(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

(d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.

Signed-off-by: @Christoffer-Cortes

Christoffer-Cortes commented 4 years ago

@sselberg @magnusbaeck I looked a bit at the rabbitmq code and saw that a BlockingQueue is created that stores events. This queue is then worked by a thread that publishes messages from this queue. I approached this issue by using a ThreadPoolExecutor. It also keeps a queue and can be set up with a number of workers. You then submit whatever piece of code you want to queue up. In our case that is the retry runnable.

magnusbaeck commented 4 years ago

ThreadPoolExecutor SGTM. As long as the caller isn't blocked and the queue size is reasonably large it's probably the best thing we can do.