Skip to content

PHPC-606: Use mongoc_server_description_t public API in Server methods #291

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

Merged
merged 5 commits into from
Apr 26, 2016

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Apr 7, 2016

https://jira.mongodb.org/browse/PHPC-606

Possible refactoring in the debug handler: serialize "last_is_master" first, and then copy the already-serialized "tags" field. Alternatively, we can decide to remove the duplicate, top-level "tags" field.

@jmikola jmikola force-pushed the phpc-606 branch 4 times, most recently from bc412be to 5117937 Compare April 19, 2016 20:59
@jmikola jmikola changed the title [WIP] PHPC-606: Use mongoc_server_description_t public API in Server methods PHPC-606: Use mongoc_server_description_t public API in Server methods Apr 19, 2016
if ((sd = mongoc_topology_description_server_by_id(&intern->client->topology->description, intern->server_id, &error))) {
RETURN_LONG(sd->round_trip_time);
if ((sd = mongoc_client_get_server_description(intern->client, intern->server_id))) {
RETVAL_LONG((phongo_long) mongoc_server_description_round_trip_time(sd));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mongoc_server_description_round_trip_time() returns an int64_t. It's unlikely that a round trip time would overflow a 32-bit integer, but are we OK with a simple cast for that edge case? This also applies to the Server's debug handler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

php_phongo_server_description_type_map_t
php_phongo_server_description_type_map[PHONGO_SERVER_DESCRIPTION_TYPES] = {
{ PHONGO_SERVER_UNKNOWN, "Unknown" },
{ PHONGO_SERVER_STANDALONE, "Standalone" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the map is from string to int, shouldn't the order be the other way around here? I.e., first string, and then the int constant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think the field order was important. Each element is a two-field struct with type and name fields. The array is technically a map from the enum integer to a string. We can technically use the array offset in lieu of storing the type field and make this an array of strings, but I figured the two-field struct was more readable.

@derickr
Copy link
Contributor

derickr commented Apr 26, 2016

LGTM

@jmikola jmikola merged commit ac19194 into mongodb:master Apr 26, 2016
jmikola added a commit that referenced this pull request Apr 26, 2016
@jmikola jmikola deleted the phpc-606 branch April 26, 2016 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants