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 the entry point for Remote Config #478

Merged
merged 4 commits into from
Sep 24, 2020
Merged

Conversation

lahirumaramba
Copy link
Member

  • Add the entry point for Remote Config services FirebaseRemoteConfig.java
  • Add unit tests to cover getTemplate() and getTemplateAsync()
  • Integration tests will be added later once all the operations are implemented

Issue: #446

Note: Merging to remote-config branch.

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 pretty good. Just one suggestion to simplify the implementation a bit.

private final FirebaseApp app;
private final Supplier<? extends FirebaseRemoteConfigClient> remoteConfigClient;

private FirebaseRemoteConfig(Builder builder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A builder is overkill for just 2 arguments. I'd recommend something simpler and direct:

@VisibleForTesting
FirebaseRemoteConfig(FirebaseApp app, FirebaseRemoteConfigClient client) {
  this.app = checkNotNull(app);
  this.client = checkNotNull(client);
}

private FirebaseRemoteConfig(FirebaseApp app) {
  this(app, FirebaseRemoteConfigClientImpl.fromApp(app));
}

Note that I'm also not using a Supplier here. Since the client is needed for all operations in this API, there's no reason to lazy initialize it.

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! Updated the code.
I had to update the unit test for testRemoteConfigClientWithoutProjectId(). As the client is now initialized at construction it throws at FirebaseRemoteConfig.getInstance().

import org.junit.Test;

public class FirebaseRemoteConfigTest {
private static final FirebaseOptions TEST_OPTIONS = FirebaseOptions.builder()
Copy link
Contributor

Choose a reason for hiding this comment

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

Add space before

@lahirumaramba
Copy link
Member Author

@hiranya911
Please note the updated testAppDelete() and testRemoteConfigClientWithoutProjectId() test cases. Thanks!

@lahirumaramba
Copy link
Member Author

@egilmorez : Please review the docs in FirebaseRemoteConfig.java. Thanks! :)

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.

LGTM with a nit.


static Builder builder() {
return new Builder();
return new FirebaseRemoteConfig(app);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove fromApp. Call constructor directly where it's needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Updated!

@hiranya911 hiranya911 removed their assignment Sep 22, 2020
/**
* This class is the entry point for all server-side Firebase Remote Config actions.
*
* <p>You can get an instance of FirebaseRemoteConfig via {@link #getInstance(FirebaseApp)}, and
Copy link
Contributor

Choose a reason for hiding this comment

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

Literal?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!

/**
* Similar to {@link #getTemplate()} but performs the operation asynchronously.
*
* @return An {@code ApiFuture} that will complete with a {@link RemoteConfigTemplate} when
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest present tense, just "completes"

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! Updated!

Copy link
Contributor

@egilmorez egilmorez left a comment

Choose a reason for hiding this comment

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

LG, thanks Lahiru!

@lahirumaramba lahirumaramba merged commit 936043b into remote-config Sep 24, 2020
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