pjfanning opened a new pull request, #664:
URL: https://github.com/apache/pekko-projection/pull/664

   ### Motivation
   Users who want to query projected data outside of a projection handler had 
to build an `R2dbcExecutor` (an internal API) to obtain an `R2dbcSession`. Akka 
Projections added `R2dbcSession.withSession` for this in 
akka/akka-projection#1017. That release (1.5.0) passed its BSL change date of 
2026-10-25, so it is now Apache 2.0 licensed.
   
   ### Modification
   - Add `R2dbcSession.withSession` to the scaladsl and javadsl `R2dbcSession` 
companions. It runs the given function with a session on a new transaction, 
committing on success and rolling back on failure. It uses the default 
`pekko.projection.r2dbc.use-connection-factory` or an explicit connection 
factory config path.
   - Adapted from upstream: DB call logging uses the projection's 
`log-db-calls-exceeding` setting. Upstream disables logging with `-1.millis`, 
but with pekko-persistence-r2dbc's `R2dbcExecutor` that logs every call at INFO 
instead.
   - Not included: the upstream change of the javadsl `select`/`selectOne` 
`mapRow` parameter from `Row => A` to `java.util.function.Function`. It is 
binary incompatible and can be raised separately if wanted.
   - The `R2dbcProjectionSpec` and `R2dbcTimestampOffsetProjectionSpec` test 
helpers now use `withSession`. Added a short note to `r2dbc.md`.
   
   ### Result
   An `R2dbcSession` can be obtained through public API in both DSLs.
   
   ### Tests
   - `sbt "r2dbc-int-test/testOnly ...R2dbcSessionSpec ...R2dbcProjectionSpec"` 
against Postgres: 36 passed
   - `sbt "r2dbc-int-test/testOnly ...R2dbcTimestampOffsetProjectionSpec"`: 
passed
   - New `R2dbcSessionSpec` covers commit and rollback for both DSLs. Before 
the change it does not compile, since the API is new, so there is no 
runtime-failing pre-fix state.
   - `sbt r2dbc/mimaReportBinaryIssues` (vs 1.0.0): no issues
   - `sbt docs/paradox`, `headerCheckAll`, scalafmt and the whitespace diff 
check: ok
   
   ### References
   Refs akka/akka-projection#1017 
(https://github.com/akka/akka-projection/pull/1017) - source of the ported code
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to