-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Support the RTDB emulator #3491
Conversation
2e9a8b4
to
66d5dd8
Compare
66d5dd8
to
e5f30d6
Compare
We still need people to be able to specify the database name (for example to test triggers), so just accepting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits.
Firebase/Database/CHANGELOG.md
Outdated
to the emulator, specify "http://<emulator_host>/" as your Database URL | ||
(via `Database.database(url:)`). | ||
If you refer to your emulator host by IP rather than by domain name, you may | ||
also need to specify a namespace ("http://<emulator_host>/?ns=<project_id>"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"namespace" => " project id" ? Or some other implementation-independent term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
bool secure; | ||
|
||
if (urlComponents.port != nil) { | ||
secure = [urlComponents.scheme isEqualToString:@"https"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, on web I think we support wss://
URLs (which IIRC disables long-polling). I wonder if we should try for some consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added support for "wss".
secure = [urlComponents.scheme isEqualToString:@"https"]; | ||
host = [host stringByAppendingFormat:@":%@", urlComponents.port]; | ||
} else if ( [urlComponents.host isEqualToString:@"localhost"]) { | ||
secure = NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we do this? Did the old code do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is not winning anyone over, so I dropped this from the iOS port (will drop the special casing for Android too).
} | ||
|
||
|
||
NSString* pathString = [self decodePath:[NSString stringWithFormat:@"/%@", originalPathString]]; | ||
FPath * path = [[FPath alloc] initWith:pathString]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like there are extra spaces here? Why does clang-format not fix that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed manually. Seems like we are excluded from the formatter (but it still takes 10 seconds to run). I'll get the formatting enabled for RTDB in a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This source is now clang-formatted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments addressed.
Firebase/Database/CHANGELOG.md
Outdated
to the emulator, specify "http://<emulator_host>/" as your Database URL | ||
(via `Database.database(url:)`). | ||
If you refer to your emulator host by IP rather than by domain name, you may | ||
also need to specify a namespace ("http://<emulator_host>/?ns=<project_id>"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
bool secure; | ||
|
||
if (urlComponents.port != nil) { | ||
secure = [urlComponents.scheme isEqualToString:@"https"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added support for "wss".
secure = [urlComponents.scheme isEqualToString:@"https"]; | ||
host = [host stringByAppendingFormat:@":%@", urlComponents.port]; | ||
} else if ( [urlComponents.host isEqualToString:@"localhost"]) { | ||
secure = NO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is not winning anyone over, so I dropped this from the iOS port (will drop the special casing for Android too).
} | ||
|
||
|
||
NSString* pathString = [self decodePath:[NSString stringWithFormat:@"/%@", originalPathString]]; | ||
FPath * path = [[FPath alloc] initWith:pathString]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed manually. Seems like we are excluded from the formatter (but it still takes 10 seconds to run). I'll get the formatting enabled for RTDB in a follow up.
This adds support for the emulator and also for the "ns" query param.\
Technically, iOS doesn't need the "ns" query param since "localhost" is a valid RTDB namespace name and we could just use "localhost" as the namespace. But since I just went all out on Android (firebase/firebase-android-sdk#680), I decided to make this PR equally awesome. Plus who doesn't like some good URL decoding/encoding mess.