Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

NC-1361 Added configurable refresh delay for SyncingSubscriptionService on start up #383

Merged
merged 18 commits into from
Dec 12, 2018

Conversation

Shinabyss
Copy link
Contributor

@Shinabyss Shinabyss commented Dec 9, 2018

PR description

Added configurable refresh delay for SyncingSubscriptionService on start up allowing user to change how often user/subscribers will sync with the node on the current state.

Config has a boundary of greater than 0 and less than 3600000 (equates to 1 hour) milliseconds.

Added Unit Testing
Not suitable for acceptance testing as acceptance testing this feature require testing the time elapse of the syncing subscriptions. This is performed by vertx hence the function is tested by vertx and secondly and more importantly, attempt to assert time delay as a form of testing can result in brittle test. For instance, setting the refresh delay to 5 seconds and run test could produce measurements on delay between 0-5 seconds and does not provide conclusive test that the config is actually set to 5 seconds. A loop can be used to retest this over and over to produce a more reliable conclusion, but this is resource and time consuming on top of still only provide a higher percentage confidence the config is correctly set and not a conclusive one. And thus as per discussion with other members of product dev team.

Fixed Issue(s)

@Shinabyss Shinabyss requested a review from macfarla December 9, 2018 17:43
@Shinabyss Shinabyss self-assigned this Dec 9, 2018
@Shinabyss Shinabyss changed the title Nc 1361 NC-1361 Added configurable refresh delay for SyncingSubscriptionService on start up Dec 10, 2018
}

public SubscriptionManager() {
this.refreshDelay = 5000;
Copy link
Contributor

Choose a reason for hiding this comment

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

use the const here rather than the number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

+ "default: ${DEFAULT-VALUE}",
defaultValue = "5000"
)
private void setRefreshDelay(final Long refreshDelay) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if I specify 1.5 ? Why long not int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vertx handles the sync function after we pass it in a value and it requires a long.
If 1.5 is entered, the CLI will pick it up as an error and warn user because only positive int below 3600000 is accepted.
long datatype are integers, they cannot take in decimals unlike double precision numbers

defaultValue = "5000"
)
private void setRefreshDelay(final Long refreshDelay) {
if (refreshDelay < 1 || refreshDelay > 3600000) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the magic numbers?

Suggestion: refactor the values into static constants with meaningful name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

5000 milliseconds is the original default when we still had it hard coded. I wanted to keep the configuration the same as the original if user started pantheon without specifying a refresh delay. Although why we decided on 5 seconds to begin with when we had it hard coded is up for debate. Do you have a better default value you would like to share?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's not what I mean when I say 'magic numbers' i.e. https://en.wikipedia.org/wiki/Magic_number_%28programming%29

throw new ParameterException(
new CommandLine(this),
"refreshDelay must be a positive integer smaller than 3600000 (1 hour)");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

recommend using MAX const in the string message here too

Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

LGTM

@Shinabyss Shinabyss merged commit 7120c77 into PegaSysEng:master Dec 12, 2018
@Shinabyss Shinabyss deleted the NC-1361 branch December 12, 2018 00:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants