3 ms·
I recently wrote some logic that's supposed to run every minute, and look at the data from the last minute. Normally I would've ended up doing queries ala event
by matsemann 3y ago
I recently wrote some logic that's supposed to run every minute, and look at the data from the last minute. Normally I would've ended up doing queries ala event_time BETWEEN now() and now() - 1m.
However, one constraint was that I needed to also run this on existing data. Which led to me instead passing in time. A small thing, but suddenly this logic beame so incredibly testable. I can call it 5 times with 5 different times and see that it behaves as expected, or simulate it over a whole day of test data. Even tweak the code a bit, delete the data it generates in prod, and re-run it with the new ruleset. So flexible.
Such a small thing, but without the additional constraint I probably wouldn't have arrived at this design.