-
Notifications
You must be signed in to change notification settings - Fork 14
Added option to spin up a server with replica set #6
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
base: master
Are you sure you want to change the base?
Conversation
… port parsing when by default was set to 0.
no message
no message
no message
no message
|
Updates on this? |
|
I'm getting Then fixed by adding "/?retryWrites=false" like this: But then this happened: Is it only me? |
|
Hi @AlexisLeon I have just fixed the issue, now I am using another storageEngine. Still waiting for them to accept the pull request but I am already using it on a private repo. If you'd like, I can make it available to you so you can add it to your go module, given than my public fork will figure as ben's library and will not allow you to get my latest version. |
|
@tuckyapps I'd love that. Thanks man |
|
Done @AlexisLeon ! Until they accept the pull request, you can use this one: https://github.com/strikesecurity/strikememongo |
benweissmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay! This is great -- just a few minor comments.
| var mongoServer memongo.Server; | ||
|
|
||
| func TestMain(m *testing.M) { | ||
| mongoServer, err = memongo.StartWitOptions(&memongo.Options{MongoVersion: "4.2.1", ShouldUseReplica: true}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this ConfigureReplicaSet? I think you need to be a little clearer in this documentation that this just configures the single server as a replica set -- but does not set up a secondary or actually perform replication. I'd suggest being pretty explicit here and say something like "This configures the Mongo server to be a replica set, and calls rs.initiate() after startup. It still only runs a single Mongo server."
| if opts.ShouldUseReplica { | ||
| mongoCommand := fmt.Sprintf("mongo --port %d --retryWrites --eval \"rs.initiate()\"", opts.Port) | ||
| //nolint:gosec | ||
| cmd2 := exec.Command("bash", "-c", mongoCommand) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should pass in the arguments individual here (as on line 68) rather than passing a Sprintf-formatted string to exec.Command. Right now it's OK because you're just templating in a numeric port number, but there's risk here that some future change will introduce a command injection vulnerability.
| if opts.ShouldUseReplica { | ||
| mongoCommand := fmt.Sprintf("mongo --port %d --retryWrites --eval \"rs.initiate()\"", opts.Port) | ||
| //nolint:gosec | ||
| cmd2 := exec.Command("bash", "-c", mongoCommand) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rsInitiateCmd instead of cmd2?
|
|
||
| // ---------- START OF REPLICA CODE ---------- | ||
| if opts.ShouldUseReplica { | ||
| mongoCommand := fmt.Sprintf("mongo --port %d --retryWrites --eval \"rs.initiate()\"", opts.Port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment here about why you're passing --retryWrites?
|
Hi, everyone! I can't start a replicaSet using strikememongo. I got this log: |
|
Hello to all contributors, after multiple documented tries to contact @benweissmann through email, linkedin and here on Github, I assumed with reasonable confidence that this project is abandoned* To solve this problem, me and @tryvium-travels team decided to fork and maintain a new version of this very project. You can check it at https://github.com/tryvium-travels/memongo Please move the PRs there if you love to @tuckyapps @AlexisLeon @dsmontoya @antonyho |
Hey,
Hope you are doing well!
Added the option, together with unit tests, to run a mongo server with replica sets. This is helpful when implementing transactions as it happens in our case.
All the best,
Santiago