Skip to content
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

Modified PNReconnectionPolicy #297

Merged
merged 6 commits into from
Dec 18, 2023
Merged

Modified PNReconnectionPolicy #297

merged 6 commits into from
Dec 18, 2023

Conversation

marcin-cebo
Copy link
Contributor

@marcin-cebo marcin-cebo commented Dec 15, 2023

fix: Added reading message type from fetch messages response.

fix: Added random value 0.001-0.999s to delay between retries both for Linear and Exponential reconnection policies.

Default and max value for maximumReconnectionRetries is 10
Added random value 0,001-2,999s to delay between retry both for Linear and Exponential policy.
}

int getNextInterval() {
int timerInterval = LINEAR_INTERVAL;
private boolean maxConnectionIsNotSetToInfinite() {
Copy link
Contributor

Choose a reason for hiding this comment

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

having negation (Not) in the middle of the name here is confusing,
how about isInfiniteReconnections ? (and flip the if to ==, and fix call sites)

Copy link
Contributor Author

@marcin-cebo marcin-cebo Dec 18, 2023

Choose a reason for hiding this comment

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

But then condition would change to:
if (!maxConnectionIsSetToInfinite() && failedCalls >= maxConnectionRetries) {

For me it is more clear to have
if (maxConnectionIsNotSetToInfinite() && failedCalls >= maxConnectionRetries) {
than
if (!maxConnectionIsSetToInfinite() && failedCalls >= maxConnectionRetries) {

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would always try to use affirmative names for boolean values (names and functions) where possible
!isSomething or even !(isSomething) for clarity is perfectly fine

with negative names there is a possibility to get double negatives which is really confusing, such as !isNotSomething()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me maxConnectionIsNotSetToInfinite reads better. I created this function to describe this mysterious condition:
maxConnectionRetries != -1
I assumed the function will not be reused. In situation !isNotSomething() is needed I would refactor it.

Anyway I will change it to maxConnectionIsSetToInfinite

@marcin-cebo
Copy link
Contributor Author

@pubnub-release-bot release as v6.4.5

@marcin-cebo marcin-cebo merged commit e4ec49a into master Dec 18, 2023
5 checks passed
@marcin-cebo marcin-cebo deleted the mc_retryPolic_tataSky branch December 18, 2023 16:40
@pubnub-release-bot
Copy link
Contributor

🚀 Release successfully completed 🚀

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.

3 participants