-
Notifications
You must be signed in to change notification settings - Fork 615
Unified emulator settings for Database #1672
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
Conversation
firebase-common/src/androidTest/java/com/google/firebase/FirebaseAppTest.java
Outdated
Show resolved
Hide resolved
Binary Size ReportAffected SDKs
Test Logs
NotesHead commit (2a276c10) is created by Prow via merging commits: a7096ac b072f54. |
The public api surface has changed for the subproject firebase-common: Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly. |
Coverage ReportAffected SDKs
Test Logs
NotesHTML coverage reports can be produced locally with Head commit (2a276c10) is created by Prow via merging commits: a7096ac b072f54. |
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 am wondering whether EmulatedServiceSettings
in firebase-common
. Wouldn't it make sense to create a dedicated library for it?
The overhead of adding+launching a new library is pretty low these days. wdyt?
@vkryachko well |
firebase-common/src/main/java/com/google/firebase/emulators/FirebaseEmulators.java
Outdated
Show resolved
Hide resolved
firebase-common/src/androidTest/java/com/google/firebase/FirebaseAppTest.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/FirebaseApp.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/FirebaseApp.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/emulators/EmulatorSettings.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/emulators/FirebaseEmulators.java
Outdated
Show resolved
Hide resolved
@KeepForSdk | ||
public void enableEmulators(@NonNull EmulatorSettings emulatorSettings) { | ||
checkNotDeleted(); | ||
Preconditions.checkState( |
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.
How will this interact with firestore's terminate()
? afaicr one can terminate one instance of firestore at which point the call to FirebaseFirestore#getInstance()
will create a new firestore instance, should we allow the following sequence of calls?
firestore.terminate();
app.updateFirestoresEmulator();
Firebase.firestore.use();
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.
Thanks for calling this out, I resolved all the other comments since they were straightforward but I will have to look into this one more deeply.
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.
Ok actually I do not want to allow that sequence of calls. One of the main reasons for this is to make sure that app developers can reason about their emulation settings at a single point before any Firebase service has done any communication.
If you call terminate()
the settings should still apply. If you want to nuke them you'll need to call FirebaseApp#delete()
and then make a new app.
WDYT?
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.
That's a good point and sgtm. You may want to confirm this behavior with firestore folks though
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.
Will do during the Firestore PR.
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 hope you have some sort of copy/paste text snippet that you can use to rebuke all my comments :)
firebase-common/src/main/java/com/google/firebase/emulators/EmulatedServiceSettings.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/emulators/EmulatorSettings.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/emulators/EmulatorSettings.java
Outdated
Show resolved
Hide resolved
if (serviceSettings != null) { | ||
repoInfo.secure = false; | ||
repoInfo.host = serviceSettings.host + ":" + serviceSettings.port; | ||
repoInfo.internalHost = repoInfo.host; |
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.
Should we add an explicit way to decide which credentials to use? I am asking because of Yuchen's feedback here: firebase/firebase-js-sdk#3228
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 do think that would be a nice addition one day but this API was approved cross-platform for Android, iOS, and JS without any mention of a credentials setting so I think I'd need to do a new API review for that.
Do you anticipate bugs like that JS one in this implementation?
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 be low risk since Android SDK is not reused in Admin SDKs. The expected behavior is the same as production -- get credentials from Firebase Auth if used and logged in, or no credentials if not.
@schmidt-sebastian all of your comments were about the FirebaseApp stuff (and they were useful!) but I added you as a database reviewer.
|
firebase-common/src/main/java/com/google/firebase/FirebaseApp.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/utilities/Utilities.java
Outdated
Show resolved
Hide resolved
firebase-database/src/main/java/com/google/firebase/database/core/utilities/Utilities.java
Outdated
Show resolved
Hide resolved
@@ -110,6 +111,9 @@ | |||
private final FirebaseOptions options; | |||
private final ComponentRuntime componentRuntime; | |||
|
|||
private final AtomicBoolean emulatorSettingsFrozen = new AtomicBoolean(false); | |||
private EmulatorSettings emulatorSettings = EmulatorSettings.getDefault(); |
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.
nit: now that settings are immutable, consider sharing the default instance across app instances.
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.
Ah yeah good call!
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 overall, a few minor comments
firebase-common/src/main/java/com/google/firebase/emulators/EmulatedServiceSettings.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/emulators/EmulatorSettings.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/emulators/FirebaseEmulator.java
Outdated
Show resolved
Hide resolved
firebase-common/src/main/java/com/google/firebase/emulators/FirebaseEmulator.java
Outdated
Show resolved
Hide resolved
…ulatedServiceSettings.java Co-authored-by: Vladimir Kryachko <[email protected]>
…rebaseEmulator.java Co-authored-by: Vladimir Kryachko <[email protected]>
…ulatorSettings.java Co-authored-by: Vladimir Kryachko <[email protected]>
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 one final getter
nit
firebase-common/src/main/java/com/google/firebase/emulators/EmulatedServiceSettings.java
Outdated
Show resolved
Hide resolved
@samtstern: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
That's unrelated and this PR was previously green, so gonna merge anyway. |
This is the first PR for http://go/firebase-emulator-connection-api
This implements the global changes needed in
FirebaseApp
as well as the changes inFirebaseDatabase
to support them.TODO:
FirebaseApp
changes so that this doesn't leak before Functions / Firestore are implemented.