[CXX-875] Database::has_collection has ambiguous error modes Created: 23/Mar/16 Updated: 19/Sep/16 Resolved: 15/Apr/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 3.0.2 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Pavel Odintsov | Assignee: | Samantha Ritter (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Hello! I'm writing application which uses Mongo. But actually sometimes mongo could not run in time due to Linux init manager issues. So I need some way to check connection to Mongodb. I deeply reviewed API documents about C++ 11 driver but could not find any way to check connection without real requests. Could you add something like this? Also function db.has_collection() haven't any way to tell about errors. And case "no connection to mongo" and "we haven't this database" handled in same way. That's not perfect |
| Comments |
| Comment by Githook User [ 15/Apr/16 ] | |||||||||||||||||||||||||
|
Author: {u'username': u'samantharitter', u'name': u'samantharitter', u'email': u'samantha.ritter@10gen.com'}Message: | |||||||||||||||||||||||||
| Comment by Samantha Ritter (Inactive) [ 12/Apr/16 ] | |||||||||||||||||||||||||
|
code review: https://github.com/mongodb/mongo-cxx-driver/pull/481 | |||||||||||||||||||||||||
| Comment by Pavel Odintsov [ 24/Mar/16 ] | |||||||||||||||||||||||||
|
Perfect! Thank you | |||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 24/Mar/16 ] | |||||||||||||||||||||||||
|
Thanks pavel.odintsov - I've updated the ticket description to capture the work we want to do and scheduled it for a release. We are hoping to release 3.0.1 this week with a number of other accumulated fixes, so I think this will need to wait until the next release after that, 3.0.2. | |||||||||||||||||||||||||
| Comment by Pavel Odintsov [ 24/Mar/16 ] | |||||||||||||||||||||||||
|
I've changed ming about separate ping function. But has_collection still a bad code ... We need return code handling here. | |||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 24/Mar/16 ] | |||||||||||||||||||||||||
|
pavel.odintsov - Have you changed your mind about has_collection as well? There seemed to be a legit complaint there that you couldn't distinguish the two error cases. | |||||||||||||||||||||||||
| Comment by Pavel Odintsov [ 24/Mar/16 ] | |||||||||||||||||||||||||
|
So we could close this ticket. | |||||||||||||||||||||||||
| Comment by Pavel Odintsov [ 24/Mar/16 ] | |||||||||||||||||||||||||
|
Hello, folks! Yep, I'm completely agree with your vision I've changed my mind | |||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 24/Mar/16 ] | |||||||||||||||||||||||||
|
I agree. I took a look at has_collection, and yeah, that isn't perfect by any means. pavel.odintsov If you are satisfied with matt.cotter's answer to the first part of your question, do you mind if I retitle this issue to be more about the flaw in has_collection? We will then get it scheduled into an upcoming release. Also, going back quickly to the comments on ping: we've kept the interface very light on "helpers", because we wanted to build a minimal API first, and then extend it based on popular demand. So your feedback here is incredibly valuable. That said, we are going to lean away from most "helpers" when the intended goal is to achievable by using the existing API, as it is via run_command. But you should feel free to argue with us from a user, rather than maintainer, perspective. We want people to use this driver, after all. | |||||||||||||||||||||||||
| Comment by Matt Cotter [ 23/Mar/16 ] | |||||||||||||||||||||||||
|
Hi pavel.odintsov, You are correct that the only way to check connectivity is to send a command. I think if we made a shortcut for sending a ping command and checking for errors, it would encourage users to just check that method and then not handle future errors. Even two subsequent calls can't be guaranteed to both have connectivity due to network failures, etc.
I agree with the critique about has_collection - I think this should throw (like list_collections and list_databases, e.g.) if the underlying operation fails. acm - thoughts on this? | |||||||||||||||||||||||||
| Comment by Pavel Odintsov [ 23/Mar/16 ] | |||||||||||||||||||||||||
|
I've implemented this task with following code:
But will be nice to have short function |