-
-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
publishing in a transaction #199
Comments
Yes, this is possible, and your idea of passing a connection in an option would work |
My organization uses pg-boss's "bring your own database connection" feature described here. Our app uses slonik for its db pool and we've written an We would like to publish our jobs as part of a transaction as well. |
@gavacho think the diff would just need to be. I haven't tested this yet:
|
@ibash I haven't tried implementing the feature but the sticky part seems to me, "what is the typescript type of the |
hmm I guess it could be whatever we want, as it wouldn't used by the default pgboss db, and would only make sense when using "bring your own database connection". I'm not super familiar with typescript, but I imagine it's an optional any for executeSql. |
I think? |
If the argument is typed as |
Put up a PR -- granted I haven't used it to encompass transactions yet. |
For anyone that needs this functionality today, we've had success with just inserting jobs directly into the job table (which can be done inside of a transaction). The job table is easy to work with and has a good set of defaults, so we use our direct-insert code instead of |
Hi.
It seems like it should be possible to publish jobs within a separate transaction, has anyone done this or are there examples of this?
This would be useful to do an all or nothing database insert (that is, insert a model in the database and also the job with it, or neither).
Is there a reason why this would be a bad idea?
From what I can tell all that would be needed is to allow passing a database connection as an option to
publish
.The text was updated successfully, but these errors were encountered: