Skip to content

Commit

Permalink
Application of the QE feedback to the Datasource guide
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Maléř <[email protected]>

Adding @asciidoclet annotation

Signed-off-by: Michal Maléř <[email protected]>
  • Loading branch information
MichalMaler committed Sep 11, 2023
1 parent 9bfc508 commit 84ff8b5
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 25 deletions.
32 changes: 23 additions & 9 deletions docs/src/main/asciidoc/datasource.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ quarkus.datasource.jdbc.max-size=16
<1> This configuration value is only required if there is more than one database extension on the classpath.

If only one viable extension is available, Quarkus assumes this is the correct one.
If a driver has been added to the test scope, Quarkus automatically includes the driver in testing.
When a driver has been added to the test scope, Quarkus automatically includes the driver in testing.

==== JDBC connection pool size adjustment

To protect your database from overloading during the transaction load peaks, size the pool adequately to throttle the database load.
The proper size always depends on many factors, such as the number of parallel application users or the nature of the workload.
Be aware that this pool size adjustment will cause some requests to time out while waiting for a connection.

For more information about pool size adjustment properties, see the xref:jdbc-configuration[] section.


=== Configure a reactive datasource

Expand Down Expand Up @@ -278,12 +287,10 @@ AgroalDataSource defaultDataSource;
In the above example, the type is `AgroalDataSource`, a `javax.sql.DataSource` subtype.
Because of this, you can also use `javax.sql.DataSource` as the injected type.


==== Reactive datasource

Quarkus offers several reactive clients for a use with reactive datasource.


. Add the corresponding extension to your application:
+
* DB2: `quarkus-reactive-db2-client`
Expand All @@ -302,6 +309,15 @@ quarkus.datasource.reactive.url=postgresql:///your_database
quarkus.datasource.reactive.max-size=20
----

===== Reactive connection pool size adjustment

To protect your database from overloading during the transaction load peaks, size the pool adequately to throttle the database load.
The proper size always depends on many factors, such as the number of parallel application users or the nature of the workload.
Be aware that this pool size adjustment will cause some requests to time out while waiting for a connection.

For more information about pool size adjustment properties, see the xref:reactive-configuration[] section.


==== JDBC and reactive datasources simultaneously

When a JDBC extension - along with Agroal - and a reactive datasource extension handling the given database kind are included, they will both be created by default.
Expand Down Expand Up @@ -450,19 +466,17 @@ Some databases like H2 and Derby are commonly used in the _embedded mode_ as a f
The recommended approach is to use the real database you intend to use in production, especially when xref:databases-dev-services.adoc[Dev Services provide a zero-config database for testing], and running tests against a container is relatively quick and produces expected results on an actual environment.
However, it is also possible to use JVM-powered databases for scenarios when the ability to run simple integration tests is required.

NOTE: While configuring Derby to use the embedded engine works as usual in JVM mode, such an application will not compile into a native executable. It is because Quarkus Derby extensions do not support embedding the entire database engine into a native executable, and it only covers making the JDBC client code compatible with the native compilation step.

==== Support and limitations

Embedded databases (H2 and Derby) work in JVM mode.
For native mode, the following limitations apply:

* Derby cannot be embedded into the application in native mode, and only remote connection is supported.
[IMPORTANT]
====
Embedding H2 within your native image is not recommended.
* Derby cannot be embedded into the application in native mode; it only supports a remote connection.
The Quarkus Derby extension allows native compilation of the Derby JDBC client, supporting only remote connections.

* Embedding H2 within your native image is not recommended.
Consider using an alternative approach, for example, using a remote connection to a separate database instead.

Check warning on line 479 in docs/src/main/asciidoc/datasource.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/datasource.adoc", "range": {"start": {"line": 479, "column": 4}}}, "severity": "INFO"}
====

==== Run an integration test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ public interface DataSourceRuntimeConfig {
/**
* The credentials provider bean name.
* <p>
* It is the {@code &#64;Named} value of the credentials provider bean. It is used to discriminate if multiple
* CredentialsProvider beans are available.
* It represents the `@Named` value of the credentials provider bean,
* which is used for discrimination when multiple `CredentialsProvider` beans are available.
* <p>
* For Vault it is: vault-credentials-provider. Not necessary if there is only one credentials provider available.
* For Vault, it is named `vault-credentials-provider`. This is not necessary if only one credentials provider is available.
* @asciidoclet
*/
@WithConverter(TrimmedStringConverter.class)
Optional<String> credentialsProviderName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface DevServicesBuildTimeConfig {
/**
* The container image name to use, for container based DevServices providers.
*
* If the provider is not container based (e.g. a H2 Database) then this has no effect.
* This has no effect if the provider is not container-based database, such as H2 or Derby.
*/
Optional<String> imageName();

Expand Down Expand Up @@ -53,7 +53,7 @@ public interface DevServicesBuildTimeConfig {
/**
* The container start command to use, for container based DevServices providers.
*
* If the provider is not container based (e.g. a H2 Database) then this has no effect.
* This has no effect if the provider is not container-based database, such as H2 or Derby.
*/
Optional<String> command();

Expand All @@ -73,9 +73,9 @@ public interface DevServicesBuildTimeConfig {
Optional<String> password();

/**
* Path to a SQL script that will be loaded from the classpath and applied to the Dev Service database
* The The path to a SQL script that will be loaded from the classpath and applied to the Dev Service database..
*
* If the provider is not container based (e.g. an H2 or Derby Database) then this has no effect.
* This has no effect if the provider is not container-based database, such as H2 or Derby.
*/
Optional<String> initScriptPath();

Expand All @@ -87,7 +87,7 @@ public interface DevServicesBuildTimeConfig {
* When using a file system location, the volume will be created with read-write permission, so the data in your file
* system might be wiped out or altered.
*
* If the provider is not container based (e.g. an H2 or Derby Database) then this has no effect.
* This has no effect if the provider is not container-based database, such as H2 or Derby.
*/
Map<String, String> volumes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ public class CredentialConfig {
/**
* The credentials provider bean name.
* <p>
* It is the {@code &#64;Named} value of the credentials provider bean. It is used to discriminate if multiple
* CredentialsProvider beans are available.
* It represents the `@Named` value of the credentials provider bean,
* which is used for discrimination when multiple `CredentialsProvider` beans are available.
* <p>
* For Vault it is: vault-credentials-provider. Not necessary if there is only one credentials provider available.
* For Vault, it is named `vault-credentials-provider`. This is not necessary if only one credentials provider is available.
* @asciidoclet
*/
@ConfigItem
@ConvertWith(TrimmedStringConverter.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public class RabbitMQBuildTimeConfig {
/**
* The credentials provider bean name.
* <p>
* It is the {@code &#64;Named} value of the credentials provider bean. It is used to discriminate if multiple
* CredentialsProvider beans are available.
* It represents the `@Named` value of the credentials provider bean,
* which is used for discrimination when multiple `CredentialsProvider` beans are available.
* <p>
* For Vault it is: vault-credentials-provider. Not necessary if there is only one credentials provider available.
* For Vault, it is named `vault-credentials-provider`. This is not necessary if only one credentials provider is available.
* @asciidoclet
*/
@ConfigItem
public Optional<String> credentialsProviderName = Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class CertificateConfig {
/**
* The credentials provider bean name.
* <p>
* It is the {@code &#64;Named} value of the credentials provider bean. It is used to discriminate if multiple
* CredentialsProvider beans are available.
* It represents the `@Named` value of the credentials provider bean,
* which is used for discrimination when multiple `CredentialsProvider` beans are available.
* It is recommended to set this property even if there is only one credentials provider currently available
* to ensure the same provider is always found in deployments where more than one provider may be available.
*/
Expand Down

0 comments on commit 84ff8b5

Please sign in to comment.