msolli / proletarian

A durable job queuing and worker system for Clojure backed by PostgreSQL.
MIT License
161 stars 7 forks source link

Use time of passed in clock for fetching jobs #13

Closed eighttrigrams closed 1 year ago

eighttrigrams commented 1 year ago

hi msolli,

this is a draft for trying to solve the following problem:

i have a setup where i want to test a larger subsystem, of which proletarian is a part. to speed up the tests, i want to pass in a clock which i can control. i expected the :proletarian/clock config argument to be for just that. however, i found out while controlling the time worked in the test cases that come with the proletarian project, in my test setup it did not work because the now() in db.clj (here in line 46) does fetch jobs based on the system clock, not on the one specifically provided as argument.

msolli commented 1 year ago

Thanks for the PR! You're absolutely right, the Clock should be used by db/get-next-job. I have some minor stylistic changes I want to make to your contribution, but I'll merge the PR and make the changes on main.

msolli commented 1 year ago

Cleanup on main in https://github.com/msolli/proletarian/commit/d34aa863f89dfcdf563a7690fcdb8f971ea26d02. Thanks again for your contribution!

eighttrigrams commented 1 year ago

Awesome! Thanks