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

adding firestore emulator client #4

Merged
merged 1 commit into from
May 18, 2020

Conversation

codestiff
Copy link
Contributor

This works but the code isn't cleaned up.
Looking for an initial review

(.setProjectId project-id)
(.setChannelProvider channel-provider)
^FirestoreOptions$Builder
(.setCredentials credentials)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I can tell the fake credentials are not used, except to guarantee validation works for the builder.

The real authorization happens using the fixed-header-provider

https://github.com/polvotech/firestore-clj/pull/4/files#diff-8dcfb082370a13ada9fe204cec4f7a1aR27

]
:profiles {:dev {:dependencies [[com.taoensso/timbre "4.10.0"]
[com.fzakaria/slf4j-timbre "0.3.19"]
[com.google.cloud/google-cloud-logging-logback "0.116.0-alpha"]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Used to pick up grpc logs in order to debug why auth was failing.

(comment
(require '[taoensso.timbre :as log])
(require '[firestore-clj.core :as f])
(def my-db (emulator-client "test-app-4" "localhost:8080"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Example usage:

bash$ firebase emulators:start --only firestore
⚠  Could not find config (firebase.json) so using defaults.
i  emulators: Starting emulators: firestore
⚠  firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
⚠  firestore: The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
i  firestore: firestore emulator logging to firestore-debug.log
✔  firestore: firestore emulator started at http://localhost:8080
i  firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
✔  emulators: All emulators started, it is now safe to connect.
(emulator-client "test-app-4" "localhost:8080") 
  => Firestore instance.
     Collections: ["accounts"]

@lurodrigo
Copy link
Owner

Thank for you for the great contribution! I'm quite busy for now and tomorrow, but I'll surely review and hopefully merge by the weekend!

@lurodrigo lurodrigo merged commit ade00e1 into lurodrigo:master May 18, 2020
@lurodrigo
Copy link
Owner

Merged! Didn't make any significant editing, just moved emulator-client to firestore-clj.core so to make it easier to refer to. Released in 1.2.1 as experimental.

If you could also add comments describing in more detail what is happening, since it seems we're being hacky here, it would be great for future maintenance. Thank you again!

@lurodrigo
Copy link
Owner

I also took the liberty of adding you to the contributors section of the README, but can delete that if it's your wish.

@codestiff
Copy link
Contributor Author

If you could also add comments describing in more detail what is happening, since it seems we're being hacky here, it would be great for future maintenance. Thank you again!

Sure thing. And yes it is being hacky. Although it is not explicitly stated in the java source code. It looks like the client is being "defensive" and only wants to allow you to configure the emulator client if you set the environment variable FIRESTORE_EMULATOR_HOST.

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.

2 participants