-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Support MongoDB session-wide write concern #3646
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c2e2897
Initial work on write concern support, set for the lifetime of the se…
calvn b8c4366
Merge branch 'master-oss' into mongodb-write-concern
calvn 8807a27
Add base64 encoded value support, include docs and tests
calvn 24f37a2
Handle error from json.Unmarshal, fix test and docs
calvn 6934d5c
Remove writeConcern struct, move JSON unmarshal to Initialize
calvn 2415f81
Return error on empty mapping of write_concern into mgo.Safe struct
calvn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -20,18 +20,26 @@ has a number of parameters to further configure a connection. | |
|
||
| Method | Path | Produces | | ||
| :------- | :--------------------------- | :--------------------- | | ||
| `POST` | `/database/config/:name` | `204 (empty body)` | | ||
| `POST` | `/database/config/:name` | `204 (empty body)` | | ||
|
||
### Parameters | ||
- `connection_url` `(string: <required>)` – Specifies the MongoDB standard connection string (URI). | ||
|
||
- `connection_url` `(string: <required>)` – Specifies the MongoDB standard | ||
connection string (URI). | ||
- `write_concern` `(string: "")` - Specifies the MongoDB [write | ||
concern][mongodb-write-concern]. This is set for the entirety of the session, | ||
maintained for the lifecycle of the plugin process. Must be a serialized JSON | ||
object, or a base64-encoded serialized JSON object. The JSON payload values | ||
map to the values in the [Safe][mgo-safe] struct from the mgo driver. | ||
|
||
### Sample Payload | ||
|
||
```json | ||
{ | ||
"plugin_name": "mongodb-database-plugin", | ||
"allowed_roles": "readonly", | ||
"connection_url": "mongodb://admin:[email protected]:27017/admin?ssl=true" | ||
"connection_url": "mongodb://admin:[email protected]:27017/admin?ssl=true", | ||
"write_concern": "{ \"wmode\": \"majority\", \"wtimeout\": 5000 }" | ||
} | ||
``` | ||
|
||
|
@@ -68,7 +76,7 @@ list the plugin does not support that statement type. | |
[MongoDB's documentation](https://docs.mongodb.com/manual/reference/method/db.createUser/). | ||
|
||
- `revocation_statements` `(string: "")` – Specifies the database statements to | ||
be executed to revoke a user. Must be a serialized JSON object, or a base64-encoded | ||
be executed to revoke a user. Must be a serialized JSON object, or a base64-encoded | ||
serialized JSON object. The object can optionally contain a "db" string. If no | ||
"db" value is provided, it defaults to the "admin" database. | ||
|
||
|
@@ -84,4 +92,7 @@ list the plugin does not support that statement type. | |
} | ||
] | ||
} | ||
``` | ||
``` | ||
|
||
[mongodb-write-concern]: https://docs.mongodb.com/manual/reference/write-concern/ | ||
[mgo-safe]: https://godoc.org/gopkg.in/mgo.v2#Safe |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Perhaps this should be an error case? If they set the WriteConcern JSON we should expect to have successfully marshaled something