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

firestore: enable a flag when emulator is used #9032

Open
raymonstah opened this issue Nov 19, 2023 · 2 comments
Open

firestore: enable a flag when emulator is used #9032

raymonstah opened this issue Nov 19, 2023 · 2 comments
Assignees
Labels
api: firestore Issues related to the Firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@raymonstah
Copy link

Is your feature request related to a problem? Please describe.
Given a firestore client, I'd like to be able to tell if the client is connected to the actual firestore servers or just the emulator.

Describe the solution you'd like
A bool on the client or a method to indicate if the client is connected to an emulator or not.

Describe alternatives you've considered
No alternatives considered.

Additional context
Happy to submit a PR for this.

@raymonstah raymonstah added the triage me I really want to be triaged. label Nov 19, 2023
@product-auto-label product-auto-label bot added the api: firestore Issues related to the Firestore API. label Nov 19, 2023
@bhshkh
Copy link
Contributor

bhshkh commented Nov 20, 2023

A client will connect to emulator only when FIRESTORE_EMULATOR_HOST environment variable is set.

The same condition can be used.

Please provide more information why a separate variable is required and the above env variable cannot be used

@raymonstah
Copy link
Author

Hey @bhshkh,

Thanks for getting back to me. I understand that when the environment variable is set, the client will connect to the emulator.

However, when working with multiple clients, it would be useful to know which client is connected to the real firestore servers, and which client is connected to the emulator. This could be useful as a safeguard so we aren't accidentally deleting data from "production" when we meant to be doing it in the emulator environment.

However, going back to your original comment, it can be awkward to set up clients that are using both an emulator and connected to the real servers, since it involves programmatically setting and unsetting the environment variable:

os.SetEnv("FIRESTORE_EMULATOR_HOST", "localhost")
// set up emulator client
os.UnsetEnv("FIRESTORE_EMULATOR_HOST")
// set up production client

@noahdietz noahdietz added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed triage me I really want to be triaged. labels Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants