timgit / pg-boss

Queueing jobs in Node.js using PostgreSQL like a boss
MIT License
1.79k stars 149 forks source link

Support singleton queue behavior for any singletonKey #329

Closed adamhamlin closed 2 years ago

adamhamlin commented 2 years ago

This updates the job_singleton_queue index to drive the special singleton queue behavior for any singletonKey that starts with __pgboss__singleton_queue--not just equal to it. In effect, this allows multiple singleton queues per job name (see discussion: https://github.com/timgit/pg-boss/discussions/285).

I included the new boolean option useSingletonQueue to prepend the passed singletonKey with __pgboss__singleton_queue. Otherwise, it has no effect.

This should not impact existing behavior UNLESS someone already had a singletonKey that is prepended with __pgboss__singleton_queue but not equal to __pgboss__singleton_queue. That seems highly unlikely.

FYI: I wasn't sure about the appropriate versioning and I had some issues running the CI tests locally. I'll add some comments about that.

timgit commented 2 years ago

@adamhamlin I'm merging this into a new tracking branch to run tests locally. Thanks!