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

Add PostgreSQL, MongoDB Atlas & MongoDB Replica Set Support #255

Merged
merged 18 commits into from
Mar 16, 2024
Merged

Add PostgreSQL, MongoDB Atlas & MongoDB Replica Set Support #255

merged 18 commits into from
Mar 16, 2024

Conversation

ProdPreva1l
Copy link
Contributor

@ProdPreva1l ProdPreva1l commented Mar 8, 2024

Adds support for PostgreSQL.
Uses all better native postgre alternatives
Adds support for srv record based mongodb atlas

…ull not null not null not null not null not null not null not null not null not null not null not null not null not null not null not null not null
# Conflicts:
#	common/src/main/java/net/william278/husksync/database/MongoDbDatabase.java
#	common/src/main/java/net/william278/husksync/database/mongo/MongoCollectionHelper.java
#	common/src/main/java/net/william278/husksync/database/mongo/MongoConnectionHandler.java
@WiIIiam278 WiIIiam278 self-assigned this Mar 8, 2024
@WiIIiam278 WiIIiam278 self-requested a review March 8, 2024 17:14
Copy link
Owner

@WiIIiam278 WiIIiam278 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work - could you update docs?

@ProdPreva1l ProdPreva1l changed the title Add PostgreSQL Support Add PostgreSQL & MongoDB Atlas Support Mar 15, 2024
…ate the config example in docs, also updates mongodb driver bc apparently i was special and very very out of data
@ProdPreva1l
Copy link
Contributor Author

Passing all tests, tested for Atlas and Postgres, also adds a safety check for UUID types on mongodb

@ProdPreva1l
Copy link
Contributor Author

dont merge, resolving an issue, appears to be that sasl1 auth is goofd

Comment on lines 69 to 72
String baseURI = "mongodb+srv://{0}:{1}@{2}/?retryWrites=true&w=majority";
baseURI = baseURI.replace("{0}", credentials.getUsername());
baseURI = baseURI.replace("{1}", credentials.getPassword());
baseURI = baseURI.replace("{2}", credentials.getHost());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
String baseURI = "mongodb+srv://{0}:{1}@{2}/?retryWrites=true&w=majority";
baseURI = baseURI.replace("{0}", credentials.getUsername());
baseURI = baseURI.replace("{1}", credentials.getPassword());
baseURI = baseURI.replace("{2}", credentials.getHost());
final Database.Type type = plugin.getSettings().getDatabase().getType();
if (type == Type.MONGO_ATLAS) {
final String uri = String.format("%s://%s:%s@%s/?retryWrites=true&w=majority",
type.getProtocol(), credentials.getUsername(), credentials.getPassword(), credentials.getHost());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to switch to String.format, but my way makes more sense in the new implementation

MONGO("MongoDB", "mongo");
POSTGRES("PostgreSQL", "postgresql"),
MONGO("MongoDB", "mongo"),
MONGO_ATLAS("MongoDB", "atlas");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MONGO_ATLAS("MongoDB", "atlas");
MONGO_ATLAS("MongoDB", "mongodb+srv");

Copy link
Contributor Author

@ProdPreva1l ProdPreva1l Mar 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been removed in favour of a mongo_settings configuration section

docs/Setup.md Show resolved Hide resolved
…nly**, allows for MongoDB Atlas, normal MongoDb AND MongoDB replica sets via the parameters in advanced mongo settings, added try and catch on all mongo operations so that it actually throws instead of a cutsie little warning
@ProdPreva1l
Copy link
Contributor Author

Breaks config for MongoDB users only

@ProdPreva1l ProdPreva1l changed the title Add PostgreSQL & MongoDB Atlas Support Add PostgreSQL, MongoDB Atlas & MongoDB Replica Set Support Mar 16, 2024
@WiIIiam278
Copy link
Owner

Nice work. Thats a better way of doing mongo :)

@WiIIiam278 WiIIiam278 merged commit 4c0addf into WiIIiam278:master Mar 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants