Commit ceb931f
authored
feat: Wire FDv2 connection-mode resolution in common_client (#279)
## Summary
Wires the FDv2 mode-resolution scaffolding (merged via #274) into the
`common_client` runtime path. Keeps the FDv1 `ConnectionMode` enum and
all existing public API signatures unchanged.
This is the first half of the further split of the original behavior PR
(#275, now closed). The follow-up flutter-only PR wires this into the
Flutter SDK.
**LDCommonClient**
- `setMode(ConnectionMode)` keeps its FDv1 signature; internally maps
the 3 legacy modes to `ResolvedConnectionMode` before forwarding to
`DataSourceManager`.
- New `setResolvedMode(ResolvedConnectionMode)` is the advanced FDv2
entry point. Documented as EAP / not-stable. **No internal caller in
this PR** -- the Flutter SDK's `ConnectionManager` invokes it in the
follow-up flutter PR.
- `DataSourceFactoriesFn` (the public, optional constructor seam) stays
typed `Map<ConnectionMode, DataSourceFactory>` so external callers can
still customize streaming + polling. `_backgroundFactory` is SDK-managed
(background is FDv2-only), and `_composeFactoriesForManager` translates
the FDv1 map into the FDv2-keyed `Map<FDv2ConnectionMode,
DataSourceFactory>` consumed by `DataSourceManager`.
**DataSourceManager** (internal, not publicly exported)
- Active mode held as `ResolvedConnectionMode`.
- Factory map keyed by `FDv2ConnectionMode`.
- `ResolvedOffline` branches dispatch status as `setOffline` /
`networkUnavailable` / `backgroundDisabled` depending on
`OfflineDetail`.
Tests updated to match.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes core data-source connection and status behavior (including
removal of manager-level network toggling); public API is preserved but
internal mode transitions and offline semantics are more complex until
the Flutter layer adopts setResolvedMode.
>
> **Overview**
> Wires **FDv2** connection-mode resolution into the `common_client`
runtime while keeping the public **`ConnectionMode`** API unchanged.
>
> **`DataSourceManager`** now tracks **`FDv2ConnectionMode`** plus
**`OfflineDetail`**, accepts **`ResolvedConnectionMode`** via `setMode`,
and keys factories by FDv2 modes (including **background**). Offline no
longer always means “set offline”: **`ResolvedOffline`** maps
**`OfflineSetOffline`**, **`OfflineNetworkUnavailable`**, and
**`OfflineBackgroundDisabled`** to the matching data-source status
without starting a connection. Internal **`setNetworkAvailable`** on the
manager is removed—network-unavailable behavior is expected to come
through resolved offline modes instead.
>
> **`LDCommonClient`** maps legacy `setMode(ConnectionMode)` to resolved
modes, adds EAP **`setResolvedMode`**, composes FDv1 custom factories
into an FDv2 factory map via **`_composeFactoriesForManager`**, and
registers an SDK-managed **background** polling factory.
`setNetworkAvailability` no longer touches the data source manager
(events only).
>
> Tests are updated for FDv2 modes and the new offline status branches.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
0921328. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 23372f9 commit ceb931f
4 files changed
Lines changed: 207 additions & 105 deletions
File tree
- packages/common_client
- lib/src
- data_sources
- test
- data_sources
Lines changed: 49 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
17 | 28 | | |
18 | 29 | | |
19 | 30 | | |
20 | 31 | | |
21 | 32 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 33 | + | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
| |||
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
38 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
39 | 52 | | |
40 | 53 | | |
41 | 54 | | |
42 | 55 | | |
43 | 56 | | |
44 | 57 | | |
45 | 58 | | |
46 | | - | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
| |||
55 | 68 | | |
56 | 69 | | |
57 | 70 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | | - | |
74 | 80 | | |
75 | | - | |
76 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
77 | 86 | | |
78 | 87 | | |
79 | 88 | | |
| |||
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
86 | | - | |
| 95 | + | |
87 | 96 | | |
88 | 97 | | |
89 | 98 | | |
| |||
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | | - | |
| 136 | + | |
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| 19 | + | |
16 | 20 | | |
| 21 | + | |
17 | 22 | | |
18 | 23 | | |
19 | 24 | | |
| |||
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
82 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
83 | 104 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
| 105 | + | |
96 | 106 | | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
100 | 110 | | |
101 | 111 | | |
102 | | - | |
| 112 | + | |
103 | 113 | | |
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
107 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
108 | 154 | | |
109 | 155 | | |
110 | 156 | | |
| |||
382 | 428 | | |
383 | 429 | | |
384 | 430 | | |
385 | | - | |
386 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
387 | 435 | | |
| 436 | + | |
388 | 437 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
395 | 441 | | |
396 | 442 | | |
397 | 443 | | |
| |||
754 | 800 | | |
755 | 801 | | |
756 | 802 | | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
757 | 817 | | |
758 | 818 | | |
759 | 819 | | |
| |||
764 | 824 | | |
765 | 825 | | |
766 | 826 | | |
767 | | - | |
768 | 827 | | |
769 | 828 | | |
770 | 829 | | |
| |||
0 commit comments