Skip to content

feat(database): enable database multi-resource support #159

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

Merged
merged 2 commits into from
Sep 14, 2017

Conversation

jshcrowthe
Copy link
Contributor

This enables database to leverage multi instance feature enabling multiple database instances per app.

Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Thanks! This basically LGTM but a few questions / comments...

*/
private repos_: {
[name: string]: Repo;
[name: string]: {
[name: string]: Repo;
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use something more specific than "name" for these? I think it's maybe appName and dbUrl or something ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, no problem.

for (const repo in this.repos_) {
this.repos_[repo].interrupt();
for (const instance in this.repos_) {
for (const repo in this.repos_[instance]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these be:
"instance" => "appName"
"repo" => "dbUrl"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, changed this and the function below.

if (repo) {
fatal('FIREBASE INTERNAL ERROR: Database initialized multiple times.');
fatal(
'Database initialized multiple times. Please make sure the format of the database URL matches with each database() call.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively we could just return the existing instance. Would that cause other problems though? I guess app would end up with multiple references to it and might call INTERNAL.delete() multiple times, etc.?

I guess I don't really feel strongly. It's probably not too harmful to make them pass the exact same URL every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't know that I'm terribly heartbroken making users pass the extra string around, especially considering that they can still just use the project config instead.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Contributor

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

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

Thanks!

@jshcrowthe jshcrowthe merged commit edad44d into master Sep 14, 2017
@jshcrowthe jshcrowthe deleted the database-multi-instance branch September 14, 2017 22:38
@firebase firebase locked and limited conversation to collaborators Oct 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants