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

Add initial classes for Remote Config API #477

Merged
merged 4 commits into from
Sep 15, 2020
Merged

Conversation

lahirumaramba
Copy link
Member

@lahirumaramba lahirumaramba commented Sep 10, 2020

  • Add FirebaseRemoteConfigClient interface and implementation
  • Add basic classes for error handing
  • Add unit tests for FirebaseRemoteConfigClientImpl

Note: merging to remote-config branch.

Related issue: #446

@lahirumaramba lahirumaramba force-pushed the lm-rc-init branch 2 times, most recently from 498018e to 74c21d3 Compare September 10, 2020 20:53
@lahirumaramba lahirumaramba marked this pull request as draft September 10, 2020 21:24
@lahirumaramba lahirumaramba marked this pull request as ready for review September 10, 2020 21:56
Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

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

Looks mostly good. I've added a series of questions and comments on things that we can clean up.

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

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

It's getting there. Just needs a bit of cleanup around error handling.

"ETag header is not available in the server response.", null, null,
RemoteConfigErrorCode.INTERNAL);
}
checkArgument(!(etagList == null || etagList.isEmpty()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps checkState is more appropriate here.

"ETag header is not available in the server response.", null, null,
RemoteConfigErrorCode.INTERNAL);
}
checkArgument(!(etagList == null || etagList.isEmpty()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Also checkState(etagList != null && !etagList.isEmpty())

"ETag header is not available in the server response.", null, null,
RemoteConfigErrorCode.INTERNAL);
}
checkArgument(!Strings.isNullOrEmpty(etag),
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too. I'd even recommend adding a getETag(IncomingResponse resp) helper method, and doing all the validation there.

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM 👍

int separator = message.indexOf(':');
if (separator != -1) {
String errorCode = message.substring(0, separator).replaceAll("\\[|\\]", "");
Matcher errorMatcher = Pattern.compile("^\\[(\\w+)\\]:.*$").matcher(message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Pattern.compile() could be expensive. Pre-compute it and store as a static 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.

Good point! Thanks!

@lahirumaramba lahirumaramba merged commit 88482db into remote-config Sep 15, 2020
@lahirumaramba lahirumaramba deleted the lm-rc-init branch September 15, 2020 20:51
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