[SERVER-31133] Add capability for ignores on the `StatusWith`'s `Status` member Created: 18/Sep/17 Updated: 30/Oct/23 Resolved: 06/Dec/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 3.7.1 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | ADAM Martin (Inactive) | Assignee: | ADAM Martin (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Sprint: | Platforms 2017-12-04, Platforms 2017-12-18 |
| Participants: |
| Description |
|
There are legitimate cases where developers wish to ignore the results of a `StatusWith` returning call. An example is `TaskExecutor::scheduleRemoteCommand`, which returns a `StatusWith< CallbackHandle >` result. A common use case which benefits from this change is one which needs to schedule background or remote "kill" style commands on that interface during some kind of destruction or shutdown. If the creation of the remote request fails, it doesn't matter, as the request was part of some kind of shutdown (often in case of failure). If the request was successful, the developer doesn't need the actual value result of the `StatusWith`, as there is no need to wait for this operation to complete. Presently, `StatusWith` has a member `getStatus` which returns the `Status` member by const reference. This means that constructions such as these are necessary to avoid problems:
or
or
or other similar ugly constructions. `StatusWith` deliberately lacks an `ignore` member, as it would be unclear to the reader which part of a `StatusWith` was being ignored – the actual return value, or the error-encoding result. Permitting `Status::ignore` to be called from the results of a `StatusWith< T >::getStatus()` call would greatly improve readability: executor->scheduleRemoteCommand( request, []( auto ) {} ).getStatus().ignore(); This is fairly trivial to implement. I already have a prototype, and a number of people have requested this kind of mechanism. |
| Comments |
| Comment by Githook User [ 06/Dec/17 ] |
|
Author: {'name': 'ADAM David Alan Martin', 'username': 'adamlsd', 'email': 'adam.martin@10gen.com'}Message: Change `StatusWith< T >::getStatus` to return `const Status &&`, which |