-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Provide a way for users to customize PgPool creation
- Loading branch information
Showing
40 changed files
with
1,520 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ctive-db2-client/runtime/src/main/java/io/quarkus/reactive/db2/client/DB2PoolCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.quarkus.reactive.db2.client; | ||
|
||
import io.quarkus.reactive.datasource.ReactiveDataSource; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.db2client.DB2ConnectOptions; | ||
import io.vertx.db2client.DB2Pool; | ||
import io.vertx.sqlclient.PoolOptions; | ||
|
||
/** | ||
* This interface is an integration point that allows users to use the {@link Vertx}, {@link PoolOptions} and | ||
* {@link DB2ConnectOptions} objects configured automatically by Quarkus, in addition to a custom strategy | ||
* for creating the final {@link DB2Pool}. | ||
* | ||
* Implementations of this class are meant to be used as CDI beans. | ||
* If a bean of this type is used without a {@link ReactiveDataSource} qualifier, then it's applied to the default datasource, | ||
* otherwise it applies to the datasource matching the name of the annotation. | ||
*/ | ||
public interface DB2PoolCreator { | ||
|
||
DB2Pool create(Input input); | ||
|
||
interface Input { | ||
|
||
Vertx vertx(); | ||
|
||
PoolOptions poolOptions(); | ||
|
||
DB2ConnectOptions db2ConnectOptions(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
.../deployment/src/test/java/io/quarkus/reactive/mssql/client/LocalhostMSSQLPoolCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.quarkus.reactive.mssql.client; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import io.vertx.mssqlclient.MSSQLPool; | ||
|
||
@Singleton | ||
public class LocalhostMSSQLPoolCreator implements MSSQLPoolCreator { | ||
|
||
@Override | ||
public MSSQLPool create(Input input) { | ||
return MSSQLPool.pool(input.vertx(), input.msSQLConnectOptions().setHost("localhost").setPort(1435), | ||
input.poolOptions()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...lient/deployment/src/test/java/io/quarkus/reactive/mssql/client/MSSQLPoolCreatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.quarkus.reactive.mssql.client; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class MSSQLPoolCreatorTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClass(CustomCredentialsProvider.class) | ||
.addClass(CredentialsTestResource.class) | ||
.addClass(LocalhostMSSQLPoolCreator.class) | ||
.addAsResource("application-credentials-with-erroneous-url.properties", "application.properties")); | ||
|
||
@Test | ||
public void testConnect() { | ||
given() | ||
.when().get("/test") | ||
.then() | ||
.statusCode(200) | ||
.body(CoreMatchers.equalTo("OK")); | ||
} | ||
|
||
} |
Oops, something went wrong.