You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[java-firestore] Ability to set emulator host/port from .setHost rather than env var #13143
@BenWhitehead I am not opposed to this, but there seems to be a much more generic problem here: It is very difficult (even for me) to figure out which of the sheer endless options I have to enable to get change even simple settings.
If we add a setHost here (and not in the main settings provider), how should we deal with conflicting settings?
I don't think that'll be any worse than now? Which is exposing all of these surfaces anyways. I feel that's a different set of problems - we need to minimize the surface, identify what's really necessary, and expose them via proper API surface. But setHost should just work. It's already there.
What you really need is a setHost(String hostname, boolean ssl, boolean useFakeCredentials). A single setHost does not help, since it still leaves a bunch of settings unset. If we need a short term fix, we could add a setEmulatorHost that does most of this for you.
I don't think a short term setEmulatorHost would necessarily be better for us maintenance wise. There is also the question about how difficult it is to bootstrap the emulator for use in java code. In datastore there is an emulator runner which allows the emulator to be started from java code, I think there is a desire to have the same thing for Firestore. With that in mind I think it'd be better for us to figure out how those will work together and then provide a good api for all emulator functionality rather than having two related but disconnected things our users have to figure out how to connect.
If we're wanting to push out a fix to help out the fact that env variables can't be modified in process, we could add a fallback java property firestore.emulator.host and try reading that. This would allow in-process configuration of that flag for users.
StringenvVar = System.getenv("FIRESTORE_EMULATOR_HOST");
StringsysProp = System.getProperty("firestore.emulator.host");
StringemulatorHost = envVar != null ? envVar : sysProp;
if (emulatorHost != null) {
// use fake creds// no ssl
}
why do we expose setHost if it's not to be used to set it to any arbitrary hosts?
does setHost take in a protocol? it actually does respect the dns:// protocol. tbh; ideally the api should've accepted a full url prefix, e.g. https://.... or http://.... emulators would only be using http
the system property would work, but no one would find that in the api or .setHost javadoc popup. we should add it to the java doc.
Activity
saturnism commentedon May 8, 2020
/cc @eddumelendez who's also working with TestContainer integration for GCP. https://github.com/eddumelendez/testcontainers-java/tree/gcloud
BenWhitehead commentedon May 11, 2020
In the same vein of googleapis/java-firestore#190.
Something I'm hoping to have time for soon, but no specific estimate.
saturnism commentedon May 12, 2020
looks like the same issue. shared an internal friction log. thnx!
schmidt-sebastian commentedon May 12, 2020
@BenWhitehead I am not opposed to this, but there seems to be a much more generic problem here: It is very difficult (even for me) to figure out which of the sheer endless options I have to enable to get change even simple settings.
If we add a
setHosthere (and not in the main settings provider), how should we deal with conflicting settings?saturnism commentedon May 12, 2020
I don't think that'll be any worse than now? Which is exposing all of these surfaces anyways. I feel that's a different set of problems - we need to minimize the surface, identify what's really necessary, and expose them via proper API surface. But
setHostshould just work. It's already there.schmidt-sebastian commentedon May 13, 2020
What you really need is a
setHost(String hostname, boolean ssl, boolean useFakeCredentials). A singlesetHostdoes not help, since it still leaves a bunch of settings unset. If we need a short term fix, we could add asetEmulatorHostthat does most of this for you.BenWhitehead commentedon May 13, 2020
I don't think a short term
setEmulatorHostwould necessarily be better for us maintenance wise. There is also the question about how difficult it is to bootstrap the emulator for use in java code. In datastore there is an emulator runner which allows the emulator to be started from java code, I think there is a desire to have the same thing for Firestore. With that in mind I think it'd be better for us to figure out how those will work together and then provide a good api for all emulator functionality rather than having two related but disconnected things our users have to figure out how to connect.If we're wanting to push out a fix to help out the fact that env variables can't be modified in process, we could add a fallback java property
firestore.emulator.hostand try reading that. This would allow in-process configuration of that flag for users.saturnism commentedon May 13, 2020
why do we expose
setHostif it's not to be used to set it to any arbitrary hosts?does
setHosttake in a protocol? it actually does respect thedns://protocol. tbh; ideally the api should've accepted a full url prefix, e.g.https://....orhttp://.... emulators would only be usinghttpthe system property would work, but no one would find that in the api or
.setHostjavadoc popup. we should add it to the java doc.feat: add method to set emulator host programmatically (#319) (#336)
chore: release 2.1.0 (#345)
[-]Ability to set emulator host/port from .setHost rather than env var[/-]