sql

isak 2023-12-13T00:20:57.316349Z

Thoughts on this postgres client? https://vertx.io/docs/vertx-pg-client/java/ Looks like it supports LISTEN well, unlike JDBC where you have to poll (AFAIK)

slipset 2023-12-13T12:48:48.663359Z

Haven’t looked into it, nor have I looked properly into https://github.com/igrishaev/pg, but that also sounds interesting πŸ™‚

πŸ‘€ 1
lukasz 2023-12-13T16:03:29.299509Z

@isak I looked into this recently (I wrote my own PG-based background job processor with extra features) and I looked into VerteX, but decided not to go for it: my main usecase was to be able to re-use the connection pool I'm already using (HikariCP) to share within a single process that handles background jobs, HTTP requests etc, and that was a deal breaker. If you go with the VertX route you have to either accept that part of your system works one way, since it's all fully async.

πŸ€” 1
isak 2023-12-13T16:44:47.830299Z

@lukaszkorecki hmm yea good points. Async might be the wrong thing to bet on now with loom released.

lukasz 2023-12-13T16:45:31.312169Z

ah yes, that's a good point - my library can technically use them now, I need to test it

lukasz 2023-12-13T16:45:35.308649Z

and open source it at some point

isak 2023-12-13T16:46:30.442609Z

Oh you made a library for this? nice

lukasz 2023-12-13T16:54:25.345479Z

Yes indeed, it's 3rd of 4th version of it at this point and I'm using it in production - it does background jobs (immediate and scheduled), has CRON support and comes with a couple of other tools that you might need (PG-based locks). It's not quite ready for open sourcing, but individual parts of it are battle tested, I just want to make sure that even if it's "alpha" quality it's usable

isak 2023-12-13T16:57:13.142439Z

Oh very cool, that is actually what I've been working on also (CRON, scheduling jobs, etc)

lukasz 2023-12-13T16:58:47.466849Z

there's a couple of libraries that do this already but I think I have an edge ;-) my CRON scheduler doesn't drift, which is an issue if you're using j.u.c.ScheduledThreadPoolExecutor so it's stable enough to handle scheduled operation that need to be as close to "wall clock" time as possible (if I'm using this term correctly). Something I learned the hard way after seeing some of the scheduled jobs firing with +/- 5m delays

😎 1
Cora (she/her) 2023-12-14T01:48:15.462289Z

ScheduledThreadPoolExecutor drifts???

lukasz 2023-12-14T02:54:03.961699Z

Yes, if you leave it running long enough it will start diverging. At first I thought that I messed up NTP setup or something, only to discover that it's not meant to be used that way in the first place. Here's a good blog post that dives into it: https://leventov.medium.com/cronscheduler-a-reliable-java-scheduler-for-external-interactions-cb7ce4a4f2cd and I wrote a wrapper around CronScheduler in the library I mentioned earlier, or you can use it directly, the API is basically the same as ScheduledThreadPoolExecutor: https://github.com/TimeAndSpaceIO/CronScheduler

lukasz 2023-12-14T02:54:20.596839Z

I really need to tidy it up and release it :-), it does more than just wrapping that library but also comes with a CRON parser and other bits.

Cora (she/her) 2023-12-14T03:18:37.539979Z

very interesting, thanks for sharing!