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

feat(rtdb): add go rtdb emulator support #517

Merged
merged 28 commits into from
Oct 28, 2022

Conversation

r-LaForge
Copy link
Contributor

@r-LaForge r-LaForge commented Oct 14, 2022

Discussion

This PR hopes to add support for the RTDB Emulator, and is discussed here: #298

There was a previous attempt here: #471

The Python and Node SDK emulation was followed as an example.

Testing

Unit tests have been added to ensure the emulator config (url + namespace) is set correctly. All others still pass.
I have also adjusted the integration tests to be able to run against the emulator.
Simply run:

# localhost:9000 simply being the default port.
 FIREBASE_DATABASE_EMULATOR_HOST=localhost:9000 FIREBASE_DATABASE_EMULATOR_NAMESPACE=<your-db> go test ./integration/db

Please note the FIREBASE_DATABASE_EMULATOR_NAMESPACE is only used to set the database name during tests.

API Changes

No public API changes.

RELEASE NOTE: The Realtime Database API now supports running against Firebase emulator suite. Enable the emulator mode by setting the FIREBASE_DATABASE_EMULATOR_HOST environment variable to point to the emulator Database endpoint.

Fixes: #298

@google-cla
Copy link

google-cla bot commented Oct 14, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment on lines +192 to +194
if strings.Contains(rawEmulatorHostURL, ".") {
namespace = strings.Split(rawEmulatorHostURL, ".")[0]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +193 to +194
func parseEmulatorHost(rawEmulatorHostURL string, parsedEmulatorHost *url.URL) (*dbURLConfig, error) {
if strings.Contains(rawEmulatorHostURL, "//") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@r-LaForge
Copy link
Contributor Author

r-LaForge commented Oct 14, 2022

I've signed the CLA check and I'm not sure why google-oss is showing up as a contributor.
image

other PRs appear to have this same issue:
#511

db/db.go Outdated Show resolved Hide resolved
@r-LaForge r-LaForge changed the title Feature/go rtdb emulator feat: add go rtdb emulator support Oct 16, 2022
@r-LaForge
Copy link
Contributor Author

Thank you for kicking off CI
I fixed the lint issue.

@lahirumaramba
Copy link
Member

I've signed the CLA check and I'm not sure why google-oss is showing up as a contributor. image

other PRs appear to have this same issue: #511

@r-LaForge I have seen this happen if we switch the base branch from to dev from the github UI. Did you by any chance based your initial changes on the main branch? If that's the case could you try rebasing to dev locally and push the changes?

@r-LaForge
Copy link
Contributor Author

r-LaForge commented Oct 24, 2022

@lahirumaramba
Thanks for checking this out.

Rebase shows branch is up to date

# dev was synched from upstream beforehand just in case.
$ git rebase dev 
Current branch feature/go-rtdb-emulator is up to date.

Branching directly from dev and creating another PR with the specific file changes results in the same outcome: #519

@lahirumaramba
Copy link
Member

Thank you so much @r-LaForge for your contribution! We will include this change in the next release of the Admin Go SDK.

@lahirumaramba lahirumaramba merged commit d6b0ca5 into firebase:dev Oct 28, 2022
@lahirumaramba lahirumaramba changed the title feat: add go rtdb emulator support feat(rtdb): add go rtdb emulator support Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants