-
Notifications
You must be signed in to change notification settings - Fork 647
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
Request for Lazy Transaction Initialization in BeginCommitRollback Middleware #431
Comments
If you only apply the middleware at the route level that would make it only applicable for that route. Are you saying a given route may or may not need to be in a transaction? |
I am using the middleware in a RPC based API. And most of the RPC frameworks (GRPC, ConnectRPC etc) make it tricky to define middleware at the route level, they typically only allow definition of middleware at the service level. |
My first thought is to somehow pass state to the Tx middleware function to just return or not. Maybe in the context. The problem is that middleware function will execute before the app layer function. My next thought is maybe you have two different muxes handling traffic. The one that needs Tx and the one that don't. Then you can set different global middleware. Then you have the mux that actually accepts the traffic. The handlers basically proxy one of the other two muxes. |
Hi, I'm using your BeginCommitRollback middleware in an app with conditional transaction needs.
First off, I want to say that the current implementation is really smooth and works great!
Is it possible to modify the middleware to initialize transactions lazily?
Ideally, the transaction would only start when GetTran is called (i.e., for handlers using .newWithTx).
This would avoid starting unnecessary transactions for endpoints that don't require them.
Any guidance or thoughts on implementing this would be greatly appreciated. Thanks!
The text was updated successfully, but these errors were encountered: