-
Notifications
You must be signed in to change notification settings - Fork 208
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
Conversation
bc412be
to
5117937
Compare
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)); |
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.
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.
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.
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" }, |
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.
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?
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.
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.
LGTM |
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.