-
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.
feat: Adding dynamic database selection support to Panache MongoDb
It supports multi-tenancy implementation following database per tenant approach, It consists in a interface called MongoDatabaseResolver that can be implemented to get the database name to be used on mongo operations execution. So if I have a MongoDatabaseResolver implementation the database to be used in the current mongo operation will be the return of resolve() method, but the resolver will be successful only for the entities that doesn't specify the database through the @MongoEntity(database="") Example: There is a "CustomMongoDatabaseResolver", a insert operation is executing, during mongo database selection the resolve method will be called and if it have returned "customerA", the selected mongo database used to execute this operation was "customerA"
- Loading branch information
1 parent
ce25570
commit 8d6c731
Showing
13 changed files
with
644 additions
and
4 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
8 changes: 8 additions & 0 deletions
8
...common/runtime/src/main/java/io/quarkus/mongodb/panache/common/MongoDatabaseResolver.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,8 @@ | ||
package io.quarkus.mongodb.panache.common; | ||
|
||
/* | ||
* This interface can be used to resolve the MongoDB database name at runtime, it allows to implement multi-tenancy using a tenant per database approach. | ||
*/ | ||
public interface MongoDatabaseResolver { | ||
String resolve(); | ||
} |
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
Oops, something went wrong.