-
Notifications
You must be signed in to change notification settings - Fork 567
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
Blocking DBClient Part 1 #6991
Comments
What if the user really wants to use |
Unlike the reactive DBClient, the blocking DBCLient API does not need an executor service, it runs on whatever thread you are running on. |
Timeout on statement execution makes sense in some corner cases. But I'd better examine JDBC API options and few other things before starting any threads. Also 1st step is to adopt existing reactive API and make 1:1 copy of blocking API/implementation. |
Signed-off-by: Tomáš Kraus <[email protected]>
…AutoCloseable Signed-off-by: Tomáš Kraus <[email protected]>
…fixed and simple DML tests are now passing. Signed-off-by: Tomáš Kraus <[email protected]>
…gration tests are passing Signed-off-by: Tomáš Kraus <[email protected]>
…n and execution Signed-off-by: Tomáš Kraus <[email protected]>
…pe from DbStatement. Code cleanup. Signed-off-by: Tomáš Kraus <[email protected]>
…pe from DbStatement. Code cleanup. Signed-off-by: Tomáš Kraus <[email protected]>
@romain-grecourt Looks like the only thing that needs close() is I'll added javadoc comments to DbStatementQuery so hope users will at least read it. |
Signed-off-by: Tomáš Kraus <[email protected]>
Progress:
|
Signed-off-by: Tomas Kraus <[email protected]>
…er tests. Signed-off-by: Tomas Kraus <[email protected]>
Signed-off-by: Tomáš Kraus <[email protected]>
Signed-off-by: Tomáš Kraus <[email protected]>
Update on closing. Making Using We can mitigate the issue by automatically closing on all terminal operations in the stream. This means the implementation has to use a stream delegate that intercepts all terminal operations in the stream. We can also have a fail-safe where the This is a win-win, as we have less boilerplate and less requirement in order to properly use the API. However, it is still possible to mis-use the stream API and consume items without using a terminal operation ; in this case the users must call |
Hi! Unsurprisingly, there is a lot of prior art when it comes to JDBC wrappers. I quite liked https://github.com/zsoltherpai/fluent-jdbc , which sports a similar API to what is worked on here. Maybe it can serve for inspiration? Thank you for working on this! 👍 Edit: I'd also like to mention https://github.com/OpenGamma/ElSql which I've used in the past for externalizing SQL. Having those two kinds of libraries together provides enough abstraction layer for many apps. Maybe something like this can be considered as an extension to the current approach? |
…ial implementation in JDBC Signed-off-by: Tomas Kraus <[email protected]>
Currently queries can be defined externally using Helidon Config, we can consider an SPI to have an extension that integrates something like ElSql. |
Signed-off-by: Tomas Kraus <[email protected]>
Signed-off-by: Tomas Kraus <[email protected]>
Signed-off-by: Tomáš Kraus <[email protected]>
…ial implementation in JDBC Signed-off-by: Tomas Kraus <[email protected]>
Signed-off-by: Tomas Kraus <[email protected]>
Signed-off-by: Tomas Kraus <[email protected]>
* Issue #6991 - Blocking DB Client: API, JDBC and Health Signed-off-by: Tomáš Kraus <[email protected]> * Issue #6991 - Blocking DB Client: Interceptors API and initial implementation in JDBC Signed-off-by: Tomas Kraus <[email protected]> * Issue #6991 - Blocking DB Client: Tracing support Signed-off-by: Tomas Kraus <[email protected]> * Issue #6991 - Blocking DB Client: Common metrics module Signed-off-by: Tomas Kraus <[email protected]> * - Fold dbclient-common into dbclient - Implement dbclient-mongodb - Re-work indexed/named parameters - Convergence between DbClientContext and DbClientExecuteContext - Generalized intercepted executions - Removed package-private factory methods in favor of constructors - Added javadocs - Copyright and checkstyle fixes * add missing newline * - Fix LRA - Fix examples/employee-app - Fix examples/dbclient * - Fix spotbugs errors - Add static factory to MongoDbClientBuilder * - Add metrics-jdbc - Add jsonp - Remove change in reactive/dbclient/jdbc * Add dbclient tests * - Rename io.helidon.dbclient.DbMapperProvider to io.helidon.dbclient.DbMapperProviderImpl to avoid confusion - Fix module-info to have uses io.helidon.dbclient.spi.DbMapperProvider - Fix connection close for transaction statements * integration tests (app) * - Fix copyright years - Consistent naming (DB Client -> Database Client) - Minize occurrences of the term "Pokemon" and use {@code Pokemon} when required. * Testing work. * Update maven-javadoc-plugin to 3.5.0 to get passed https://issues.apache.org/jira/browse/MJAVADOC-677 * Rebased on main, fixes to dbclient metrics Signed-off-by: Tomas Langer <[email protected]> --------- Signed-off-by: Tomáš Kraus <[email protected]> Signed-off-by: Tomas Kraus <[email protected]> Signed-off-by: Tomas Langer <[email protected]> Co-authored-by: Romain Grecourt <[email protected]> Co-authored-by: Tomas Langer <[email protected]>
This issue tracks the work done for 4.0.0-M1. For follow-up work see issue #7187 |
Here is the initial proposal for the update of DBClient to a blocking style API.
DbExecute.
AutoClosable
Note the use of
AutoClosable
.In the blocking style,
onComplete
is achieved by the next statement.onError
is achieved by a try-catch block:DbExecute
should work like a session, where the object can be used multiple times to perform database operations.If
DbExecute
is designed as single-use, we should introduce aDbSession
class that implementsAutoClosable
.The try-with-resources block represents code that uses a session:
Transaction
DbTransaction
extendsDbExecute
and defines a contract wherecommit()
MUST be called.When the auto
close()
is called, all non-committed and non rollbacked transactions are rollbacked.Stream.close
Use
Stream
close handler as an API to close the relatedResultSet
(for JDBC). However sinceStream
does not require try-with-resources, hook the closing of the stream as part of the enclosingAutoClosable
(I.e.DbExecute
).This means, if the user uses a
Stream
produced byDbStatementQuery
outside of a try-with-resources, then the stream is unusable.The creation of the
Stream<DbRow>
can be done like this:Boxed Long
Remove the result type parameter from
DbStatement
in order to avoid forcing a boxedLong
as a return type.This means that the
execute
method has to be defined in all sub interfaces ofDbStatement
:Interceptor
Update the interceptor mechanism to be blocking friendly similar to
WebClientService
:MongoDB
MongoDB
, throw anUnsupportException
intransaction()
Misc
dbclient/common
in the main moduleExecutorService
related codeThe text was updated successfully, but these errors were encountered: