-
Notifications
You must be signed in to change notification settings - Fork 209
PHPC-827: Update Max Staleness implementation #469
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
PHPC-827: Update Max Staleness implementation #469
Conversation
37bcbae
to
4a0f8bc
Compare
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be <= %" PRId32 ", %" PHONGO_LONG_FORMAT " given", INT32_MAX, maxStalenessSeconds); | ||
return; | ||
} | ||
if (maxStalenessSeconds > 0 && mode == MONGOC_READ_PRIMARY) { |
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.
This should check if it's not equal to NO_MAX_STALENESS
.
}, 'MongoDB\Driver\Exception\InvalidArgumentException'), "\n"; | ||
|
||
echo throws(function() { | ||
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessMS' => -1]); | ||
new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY, null, ['maxStalenessSeconds' => -2]); |
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.
Let's add test cases for 0
(another boundary case) and 42
(something less than 90) as well.
}, "MongoDB\Driver\Exception\InvalidArgumentException"), "\n"; | ||
|
||
echo throws(function() { | ||
$manager = new MongoDB\Driver\Manager(null, ['readPreference' => 'secondary', 'maxStalenessMS' => -1]); | ||
$manager = new MongoDB\Driver\Manager(null, ['readPreference' => 'secondary', 'maxStalenessSeconds' => -2]); |
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.
Let's add test cases for 0
(another boundary case) and 42
(something less than 90) as well.
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.
LGTM with comparison fix (see comment) and additional invalid test cases.
4a0f8bc
to
6f6f69e
Compare
7479e44
to
46c2fe6
Compare
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected maxStalenessSeconds to be <= %" PRId32 ", %" PHONGO_LONG_FORMAT " given", INT32_MAX, maxStalenessSeconds); | ||
return; | ||
} | ||
if (maxStalenessSeconds != MONGOC_NO_MAX_STALENESS && mode == MONGOC_READ_PRIMARY) { |
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 just realized this is redundant since we're already within a maxStalenessSeconds != MONGOC_NO_MAX_STALENESS
conditional. No harm in leaving this in place, though. We can always refactor later.
The expected output of bson-javascript-jsonserialize-004.phpt is logically incorrect because of an outstanding bug where Javascript objects are always serialized to BSON code types, irrespective of their scope property. That issue will be fixed by PHPC-838.
46c2fe6
to
5c63b8d
Compare
https://jira.mongodb.org/browse/PHPC-827
https://jira.mongodb.org/browse/PHPC-791
https://jira.mongodb.org/browse/PHPC-838
https://jira.mongodb.org/browse/PHPC-459