-
Notifications
You must be signed in to change notification settings - Fork 18
feat: Wire FDv2 connection-mode resolution in flutter SDK #280
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
Open
tanderson-ld
wants to merge
3
commits into
ta/SDK-2187/connection-mode-and-resolution-common
Choose a base branch
from
ta/SDK-2187/connection-mode-and-resolution-flutter
base: ta/SDK-2187/connection-mode-and-resolution-common
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
2e88c21
feat(SDK-2187): Wire FDv2 connection-mode resolution in flutter SDK
tanderson-ld 64f3cee
Merge branch 'ta/SDK-2187/connection-mode-and-resolution-common' into…
tanderson-ld a150a73
refactor(SDK-2187): ConnectionManager setMode takes FDv2ConnectionMode
tanderson-ld File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
18 changes: 10 additions & 8 deletions
18
packages/flutter_client_sdk/lib/src/config/defaults/flutter_default_config.dart
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 |
|---|---|---|
| @@ -1,20 +1,22 @@ | ||
| import 'package:launchdarkly_common_client/launchdarkly_common_client.dart'; | ||
|
|
||
| import 'stub_config.dart' | ||
| if (dart.library.io) 'io_config.dart' | ||
| if (dart.library.js_interop) 'js_config.dart'; | ||
|
|
||
| /// Configuration common to web and mobile is contained in this file. | ||
| /// | ||
| /// Configuration specific to either io targets or js targets are in io_config | ||
| /// and js_config and then exposed through this file. | ||
|
|
||
| final class DefaultApplicationEventsConfig { | ||
| final defaultBackgrounding = true; | ||
| final defaultNetworkAvailability = true; | ||
| } | ||
| /// Native IO and web-specific defaults live in `io_config.dart` and | ||
| /// `js_config.dart` and are exposed through this file. | ||
|
|
||
| final class FlutterDefaultConfig { | ||
| static final ConnectionManagerConfig connectionManagerConfig = | ||
| ConnectionManagerConfig(); | ||
|
|
||
| static final applicationEventsConfig = DefaultApplicationEventsConfig(); | ||
| /// Default automatic-resolution background slot. | ||
| static FDv2ConnectionMode get defaultBackgroundConnectionMode => | ||
| connectionManagerConfig.defaultBackgroundConnectionMode; | ||
|
|
||
| static final ApplicationEventsConfig applicationEventsConfig = | ||
| ApplicationEventsConfig(); | ||
| } |
20 changes: 20 additions & 0 deletions
20
packages/flutter_client_sdk/lib/src/config/defaults/io_config.dart
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 |
|---|---|---|
| @@ -1,6 +1,26 @@ | ||
| import 'dart:io' show Platform; | ||
|
|
||
| import 'package:launchdarkly_common_client/launchdarkly_common_client.dart'; | ||
|
|
||
| class ConnectionManagerConfig { | ||
| bool get runInBackground => | ||
| Platform.isLinux || Platform.isWindows || Platform.isMacOS; | ||
|
|
||
| FDv2ConnectionMode get defaultBackgroundConnectionMode => | ||
| Platform.isAndroid || Platform.isIOS || Platform.isFuchsia | ||
| ? const FDv2Background() | ||
| : const FDv2Offline(); | ||
| } | ||
|
|
||
| /// Platform defaults for [ApplicationEvents] on native IO targets. | ||
| /// | ||
| /// Mobile uses application and network signals for automatic connection | ||
| /// handling; desktop IO targets do not by default. | ||
| final class ApplicationEventsConfig { | ||
| bool get _isMobile => | ||
| Platform.isAndroid || Platform.isIOS || Platform.isFuchsia; | ||
|
|
||
| bool get defaultBackgrounding => _isMobile; | ||
|
|
||
| bool get defaultNetworkAvailability => _isMobile; | ||
| } |
14 changes: 14 additions & 0 deletions
14
packages/flutter_client_sdk/lib/src/config/defaults/js_config.dart
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 |
|---|---|---|
| @@ -1,3 +1,17 @@ | ||
| import 'package:launchdarkly_common_client/launchdarkly_common_client.dart'; | ||
|
|
||
| class ConnectionManagerConfig { | ||
| bool get runInBackground => true; | ||
|
|
||
| FDv2ConnectionMode get defaultBackgroundConnectionMode => const FDv2Offline(); | ||
| } | ||
|
|
||
| /// Platform defaults for [ApplicationEvents] on web. | ||
| /// | ||
| /// Web does not use application or network detector signals for automatic | ||
| /// connection handling by default. | ||
| final class ApplicationEventsConfig { | ||
| bool get defaultBackgrounding => false; | ||
|
|
||
| bool get defaultNetworkAvailability => false; | ||
| } |
11 changes: 11 additions & 0 deletions
11
packages/flutter_client_sdk/lib/src/config/defaults/stub_config.dart
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 |
|---|---|---|
| @@ -1,3 +1,14 @@ | ||
| import 'package:launchdarkly_common_client/launchdarkly_common_client.dart'; | ||
|
|
||
| class ConnectionManagerConfig { | ||
| bool get runInBackground => throw Exception('Stub implementation'); | ||
|
|
||
| FDv2ConnectionMode get defaultBackgroundConnectionMode => const FDv2Offline(); | ||
| } | ||
|
|
||
| /// Stub defaults for tests and unsupported compilation targets. | ||
| final class ApplicationEventsConfig { | ||
| bool get defaultBackgrounding => false; | ||
|
|
||
| bool get defaultNetworkAvailability => false; | ||
| } |
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.
Oops, something went wrong.
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.
This is sorta ok if initialConnectionMode is never expected to be background. The asymmetry between initialConnectionMode and backgroundConnectionMode isn't great, but it would require a breaking change to make them symmetric. Thoughts?