Skip to content
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

Adding multi-tenancy support to MongoDb Panache throught dynamic database selection #29192

Conversation

pedroh-pereira
Copy link
Contributor

@pedroh-pereira pedroh-pereira commented Nov 10, 2022

Based on #14789

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="")

Disclaimer:
After this PR be approved I can help to provide a detailed documentation

@loicmathieu @evanchooly

@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Nov 10, 2022
@quarkus-bot quarkus-bot bot removed the triage/invalid This doesn't seem right label Nov 10, 2022
@pedroh-pereira pedroh-pereira force-pushed the feat/#14789-adding-panache-database-resolver branch 4 times, most recently from 4e5393e to 5592f19 Compare November 14, 2022 13:07
pedroh-pereira added a commit to pedroh-pereira/quarkus that referenced this pull request Nov 14, 2022
- Removing unused import from BeanUtils
- Removing unnecessary nested class from ResolverEntityWithDatabase
- Removing unused ResolversPropertiesConstants
- Removing the method BeanUtils.getValueFromArcInstance, so BeanUtils.getDatabaseNameFromResolver will get the information directly
@pedroh-pereira pedroh-pereira force-pushed the feat/#14789-adding-panache-database-resolver branch from 5c24466 to 0977a71 Compare November 14, 2022 19:28
@quarkus-bot quarkus-bot bot added area/arc Issue related to ARC (dependency injection) area/cli Related to quarkus cli (not maven/gradle/etc.) area/core area/dependencies Pull requests that update a dependency file area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/documentation area/gradle Gradle area/infra-automation anything related to CI, bots, etc. that are used to automated our infrastructure area/jakarta area/jbang Issues related to when using jbang.dev with Quarkus area/kafka area/kubernetes area/logging area/maven area/oidc area/platform Issues related to definition and interaction with Quarkus Platform area/qute The template engine labels Nov 14, 2022
@pedroh-pereira pedroh-pereira force-pushed the feat/#14789-adding-panache-database-resolver branch from 46f566c to 6643132 Compare November 21, 2022 17:58
@quarkus-bot

This comment has been minimized.

@pedroh-pereira pedroh-pereira requested review from loicmathieu and gsmet and removed request for gsmet and loicmathieu November 21, 2022 19:26
@pedroh-pereira pedroh-pereira changed the title Adding MongoDatabaseResolver to be used in a multi-tenancy environment Adding multi-tenancy support to MongoDb Panache throught dynamic database selection Nov 21, 2022
@pedroh-pereira
Copy link
Contributor Author

pedroh-pereira commented Nov 22, 2022

It misses the documentation part in the guides.

I think the test is not very accurate about a real use case. It mock the resolver and everything lies in the test directory.

We usually test new functionalities in a more "real world" manner.

For ex:

  • Create a resolver that resvole the database name from a request header
  • At startup, add "red" in a collection in database1 and "blue" in the same collection in database2
  • Create a REST endpoint (or enhance an existing one) with an operation that get the red/blue from the database
  • Test from restassured that when you pass the header "blue" you get "blue" from the database

This will also be a good example for the guide.

@loicmathieu @evanchooly @gsmet Done

@pedroh-pereira pedroh-pereira force-pushed the feat/#14789-adding-panache-database-resolver branch 6 times, most recently from 8d6c731 to 934c602 Compare November 29, 2022 02:40
@pedroh-pereira pedroh-pereira requested review from evanchooly and removed request for loicmathieu November 29, 2022 02:40
@pedroh-pereira pedroh-pereira force-pushed the feat/#14789-adding-panache-database-resolver branch from 934c602 to aa1741c Compare November 29, 2022 13:42
@pedroh-pereira pedroh-pereira requested review from gsmet and loicmathieu and removed request for evanchooly and gsmet November 29, 2022 13:48
@pedroh-pereira pedroh-pereira force-pushed the feat/#14789-adding-panache-database-resolver branch from aa1741c to 7e90ca3 Compare December 1, 2022 19:29
@pedroh-pereira pedroh-pereira force-pushed the feat/#14789-adding-panache-database-resolver branch from 7e90ca3 to dd9eebe Compare December 4, 2022 14:59
@quarkus-bot quarkus-bot bot added the triage/invalid This doesn't seem right label Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants