acaloiaro / neoq

Queue-agnostic background job library for Go, with a pleasant API and powerful features.
MIT License
270 stars 4 forks source link

chore(test): Adding a test for multiple consumers with the pg backend. #75

Closed elliotcourant closed 1 year ago

elliotcourant commented 1 year ago

This test is to provide a minimal proof that jobs can be consumed by multiple workers and in a way can only be consumed once. If the execCount does not match the expected count then this test will fail because either too many jobs were executed (like one executing twice) or a job was dropped when it should not have been.


I used a waitgroup for this since I want to make sure multiple jobs complete on their own time and in any order. But a waitgroup removes any natural timeout handling and instead forces the go test process to handle timeouts instead. This might not be ideal but would only happen when there was such a significant change to the PG backend that a job does not get processed for some reason?

elliotcourant commented 1 year ago

I plan on using neoq in an environment where I have multiple workers and multiple producers or enqueuers with a PostgreSQL backend. I didn't see any tests for this exact use case and thought it would be valuable to add some.

There are some more tests that I want to add but figured I'd throw this up first for initial feedback.