Merged
Changes from all commits
Show all changes
15 commitsSelect commit Hold shift + click to select a range
721b46d
fix(firestore): expose on FireStoreSettings
93a56f8
fix(firestore): expose on FireStoreSettings
921b46b
fix(firestore): change experimentalForceLongPolling to webExperimenta…
SelaseKaybfc142b
feat(firestore, web): expose (webExperimentalAutoDetectLongPolling, w…
SelaseKay51f2056
correct variable name
SelaseKay4b6f081
abstract timeoutDuration within an object
SelaseKay4cce27a
remove description on webExperimentalLongPollingOptions field
SelaseKay4c08161
resolve documentation
SelaseKayb8f2e58
fix analyzer issues
SelaseKayb8a9b92
test(firestore, web): add e2e tests for long polling fields
SelaseKay8283e58
test(firestore, web): add e2e tests for long polling fields
SelaseKayac53e87
remove skip field from test
SelaseKay75ec398
remove unused import
SelaseKay9ba6925
tests(firestore,web): make adjustments long polling tests
SelaseKay2c36f41
tests(firestore,web): make adjustments long polling tests
SelaseKayFile filter
Filter by extension
Conversations
Failed to load comments.
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Failed to load files.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2020, the Chromium project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
void runSettingsTest() { | ||
group( | ||
'$Settings', | ||
() { | ||
late FirebaseFirestore firestore; | ||
setUpAll(() async { | ||
firestore = FirebaseFirestore.instance; | ||
}); | ||
Future<Settings> initializeTest() async { | ||
Settings firestoreSettings = const Settings( | ||
persistenceEnabled: false, | ||
webExperimentalForceLongPolling: true, | ||
webExperimentalAutoDetectLongPolling: true, | ||
webExperimentalLongPollingOptions: WebExperimentalLongPollingOptions( | ||
timeoutDuration: Duration(seconds: 15), | ||
), | ||
); | ||
return firestore.settings = firestoreSettings; | ||
} | ||
testWidgets('checks if long polling settings were applied', (_) async { | ||
Settings settings = await initializeTest(); | ||
expect(settings.webExperimentalForceLongPolling, true); | ||
expect(settings.webExperimentalAutoDetectLongPolling, true); | ||
expect( | ||
settings.webExperimentalLongPollingOptions, | ||
settings.webExperimentalLongPollingOptions, | ||
); | ||
}); | ||
}, | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -16,6 +16,9 @@ class Settings { | ||
this.host, | ||
this.sslEnabled, | ||
this.cacheSizeBytes, | ||
this.webExperimentalForceLongPolling, | ||
this.webExperimentalAutoDetectLongPolling, | ||
this.webExperimentalLongPollingOptions, | ||
this.ignoreUndefinedProperties = false, | ||
}); | ||
@@ -51,13 +54,39 @@ class Settings { | ||
/// Web only. | ||
final bool ignoreUndefinedProperties; | ||
/// Forces the SDK’s underlying network transport (WebChannel) to use long-polling. | ||
/// | ||
/// Each response from the backend will be closed immediately after the backend sends data | ||
/// (by default responses are kept open in case the backend has more data to send). | ||
/// This avoids incompatibility issues with certain proxies, antivirus software, etc. | ||
/// that incorrectly buffer traffic indefinitely. | ||
/// Use of this option will cause some performance degradation though. | ||
final bool? webExperimentalForceLongPolling; | ||
/// Configures the SDK's underlying transport (WebChannel) to automatically detect if long-polling should be used. | ||
/// | ||
///This is very similar to [webExperimentalForceLongPolling], but only uses long-polling if required. | ||
final bool? webExperimentalAutoDetectLongPolling; | ||
/// Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used. | ||
/// | ||
/// These options are only used if experimentalForceLongPolling is true | ||
/// or if [webExperimentalAutoDetectLongPolling] is true and the auto-detection determined that long-polling was needed. | ||
/// Otherwise, these options have no effect. | ||
final WebExperimentalLongPollingOptions? webExperimentalLongPollingOptions; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a documentation here Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.These options are only used if experimentalForceLongPolling is true or if experimentalAutoDetectLongPolling is true and the auto-detection determined that long-polling was needed. Otherwise, these options have no effect. | ||
/// Returns the settings as a [Map] | ||
Map<String, dynamic> get asMap { | ||
return { | ||
'persistenceEnabled': persistenceEnabled, | ||
'host': host, | ||
'sslEnabled': sslEnabled, | ||
'cacheSizeBytes': cacheSizeBytes, | ||
'webExperimentalForceLongPolling': webExperimentalForceLongPolling, | ||
'webExperimentalAutoDetectLongPolling': | ||
webExperimentalAutoDetectLongPolling, | ||
'webExperimentalLongPollingOptions': | ||
webExperimentalLongPollingOptions?.asMap, | ||
if (kIsWeb) 'ignoreUndefinedProperties': ignoreUndefinedProperties, | ||
}; | ||
} | ||
@@ -67,7 +96,10 @@ class Settings { | ||
String? host, | ||
bool? sslEnabled, | ||
int? cacheSizeBytes, | ||
bool? webExperimentalForceLongPolling, | ||
bool? webExperimentalAutoDetectLongPolling, | ||
bool? ignoreUndefinedProperties, | ||
WebExperimentalLongPollingOptions? webExperimentalLongPollingOptions, | ||
}) { | ||
assert( | ||
cacheSizeBytes == null || | ||
@@ -81,6 +113,13 @@ class Settings { | ||
host: host ?? this.host, | ||
sslEnabled: sslEnabled ?? this.sslEnabled, | ||
cacheSizeBytes: cacheSizeBytes ?? this.cacheSizeBytes, | ||
webExperimentalForceLongPolling: webExperimentalForceLongPolling ?? | ||
this.webExperimentalForceLongPolling, | ||
webExperimentalAutoDetectLongPolling: | ||
webExperimentalAutoDetectLongPolling ?? | ||
this.webExperimentalAutoDetectLongPolling, | ||
webExperimentalLongPollingOptions: webExperimentalLongPollingOptions ?? | ||
this.webExperimentalLongPollingOptions, | ||
ignoreUndefinedProperties: | ||
ignoreUndefinedProperties ?? this.ignoreUndefinedProperties, | ||
); | ||
@@ -94,6 +133,12 @@ class Settings { | ||
other.host == host && | ||
other.sslEnabled == sslEnabled && | ||
other.cacheSizeBytes == cacheSizeBytes && | ||
other.webExperimentalForceLongPolling == | ||
webExperimentalForceLongPolling && | ||
other.webExperimentalAutoDetectLongPolling == | ||
webExperimentalAutoDetectLongPolling && | ||
other.webExperimentalLongPollingOptions == | ||
webExperimentalLongPollingOptions && | ||
other.ignoreUndefinedProperties == ignoreUndefinedProperties; | ||
@override | ||
@@ -103,9 +148,46 @@ class Settings { | ||
host, | ||
sslEnabled, | ||
cacheSizeBytes, | ||
webExperimentalForceLongPolling, | ||
webExperimentalAutoDetectLongPolling, | ||
webExperimentalLongPollingOptions, | ||
ignoreUndefinedProperties, | ||
); | ||
@override | ||
String toString() => 'Settings($asMap)'; | ||
} | ||
/// Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used. | ||
@immutable | ||
class WebExperimentalLongPollingOptions { | ||
/// The desired maximum timeout interval, in seconds, to complete a long-polling GET response | ||
/// | ||
/// Valid values are between 5 and 30, inclusive. | ||
/// By default, when long-polling is used the "hanging GET" request sent by the client times out after 30 seconds. | ||
/// To request a different timeout from the server, set this setting with the desired timeout. | ||
/// Changing the default timeout may be useful, for example, | ||
/// if the buffering proxy that necessitated enabling long-polling in the first place has a shorter timeout for hanging GET requests, | ||
/// in which case setting the long-polling timeout to a shorter value, | ||
/// such as 25 seconds, may fix prematurely-closed hanging GET requests. | ||
final Duration? timeoutDuration; | ||
const WebExperimentalLongPollingOptions({ | ||
this.timeoutDuration, | ||
}); | ||
Map<String, dynamic> get asMap { | ||
return { | ||
'timeoutDuration': timeoutDuration?.inSeconds, | ||
}; | ||
} | ||
@override | ||
bool operator ==(Object other) => | ||
other is WebExperimentalLongPollingOptions && | ||
other.runtimeType == runtimeType && | ||
other.timeoutDuration == timeoutDuration; | ||
@override | ||
int get hashCode => Object.hash(runtimeType, timeoutDuration); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.
Missing a documentation here
Options that configure the SDK’s underlying network transport (WebChannel) when long-polling is used.These options are only used if experimentalForceLongPolling is true or if experimentalAutoDetectLongPolling is true and the auto-detection determined that long-polling was needed. Otherwise, these options have no effect.