-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support MongoDB session-wide write concern (#3646)
* Initial work on write concern support, set for the lifetime of the session * Add base64 encoded value support, include docs and tests * Handle error from json.Unmarshal, fix test and docs * Remove writeConcern struct, move JSON unmarshal to Initialize * Return error on empty mapping of write_concern into mgo.Safe struct
- Loading branch information
Showing
3 changed files
with
89 additions
and
5 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
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 |