Skip to content

Commit 9f912e7

Browse files
authored
feat!: Remove the FDv1 data system (#573)
1 parent 8175725 commit 9f912e7

81 files changed

Lines changed: 647 additions & 9826 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,7 @@ jobs:
5454
- name: start contract test service
5555
run: make start-contract-test-service-bg
5656

57-
- name: Run contract tests v2
58-
uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1
59-
with:
60-
test_service_port: 9000
61-
token: ${{ secrets.GITHUB_TOKEN }}
62-
stop_service: "false"
63-
enable_persistence_tests: "true"
64-
65-
- name: Run contract tests v3
57+
- name: Run contract tests
6658
uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1
6759
with:
6860
test_service_port: 9000
@@ -77,15 +69,7 @@ jobs:
7769
- name: start async contract test service
7870
run: make start-async-contract-test-service-bg
7971

80-
- name: Run async contract tests v2
81-
uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1
82-
with:
83-
test_service_port: 9001
84-
token: ${{ secrets.GITHUB_TOKEN }}
85-
stop_service: "false"
86-
enable_persistence_tests: "true"
87-
88-
- name: Run async contract tests v3
72+
- name: Run async contract tests
8973
uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1
9074
with:
9175
test_service_port: 9001
@@ -166,6 +150,7 @@ jobs:
166150
test_service_port: 9000
167151
enable_persistence_tests: "false"
168152
token: ${{ secrets.GITHUB_TOKEN }}
153+
version: v3
169154

170155
- name: Start the async contract test service from the sdist
171156
working-directory: ${{ runner.temp }}/sdist
@@ -177,6 +162,7 @@ jobs:
177162
test_service_port: 9001
178163
enable_persistence_tests: "false"
179164
token: ${{ secrets.GITHUB_TOKEN }}
165+
version: v3
180166

181167
windows:
182168
runs-on: windows-latest

‎Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ start-async-contract-test-service-bg:
8181

8282
.PHONY: run-contract-tests
8383
run-contract-tests:
84-
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v2/downloader/run.sh \
85-
| VERSION=v2 PARAMS="-url http://localhost:$(PORT) -debug -stop-service-at-end" sh
84+
@curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/v3/downloader/run.sh \
85+
| VERSION=v3 PARAMS="-url http://localhost:$(PORT) -debug -stop-service-at-end" sh
8686

8787
.PHONY: contract-tests
8888
contract-tests: #! Run the contract test harness

‎contract-tests/async_client_entity.py‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,6 @@ async def start(self):
8484
datasystem_config = config_params.get('dataSystem')
8585
if datasystem_config is not None:
8686
opts["datasystem_config"] = _build_async_data_system(datasystem_config, opts)
87-
elif config_params.get("streaming") is not None:
88-
streaming = config_params["streaming"]
89-
if streaming.get("baseUri") is not None:
90-
opts["stream_uri"] = streaming["baseUri"]
91-
if streaming.get("filter") is not None:
92-
opts["payload_filter_key"] = streaming["filter"]
93-
_set_optional_time_prop(streaming, "initialRetryDelayMs", opts, "initial_reconnect_delay")
94-
elif config_params.get("polling") is not None:
95-
opts['stream'] = False
96-
polling = config_params["polling"]
97-
if polling.get("baseUri") is not None:
98-
opts["base_uri"] = polling["baseUri"]
99-
if polling.get("filter") is not None:
100-
opts["payload_filter_key"] = polling["filter"]
101-
_set_optional_time_prop(polling, "pollIntervalMs", opts, "poll_interval")
102-
elif not endpoints.get('streaming') and not endpoints.get('polling'):
103-
# No data source config and no streaming or polling endpoint means daemon mode.
104-
# A config that sets only an endpoint gets the default streaming data source.
105-
opts['use_ldd'] = True
10687

10788
if config_params.get("events") is not None:
10889
events = config_params["events"]
@@ -135,9 +116,6 @@ async def start(self):
135116
_set_optional_time_prop(big_params, "staleAfterMs", big_config, "stale_after")
136117
opts["big_segments"] = AsyncBigSegmentsConfig(**big_config)
137118

138-
if config_params.get("persistentDataStore") is not None:
139-
opts["feature_store"] = _create_async_persistent_store(config_params["persistentDataStore"])
140-
141119
start_wait = config_params.get("startWaitTimeMs") or 5000
142120
sdk_config = AsyncConfig(**opts)
143121

‎contract-tests/async_service.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ async def handle_status(request: aiohttp.web.Request) -> aiohttp.web.Response:
5151
'all-flags-details-only-for-tracked-flags',
5252
'big-segments',
5353
'context-type',
54-
'filtering',
5554
'secure-mode-hash',
5655
'tags',
5756
'event-gzip',
@@ -69,8 +68,6 @@ async def handle_status(request: aiohttp.web.Request) -> aiohttp.web.Response:
6968
'migrations',
7069
'persistent-data-store-redis',
7170
'fdv1-fallback',
72-
'retry-conformance-fdv1-streaming',
73-
'retry-conformance-fdv1-polling',
7471
'service-endpoints',
7572
'wrapper',
7673
'http-proxy',

‎contract-tests/client_entity.py‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -131,26 +131,6 @@ def __init__(self, tag, config):
131131

132132
opts["datasystem_config"] = datasystem.build()
133133

134-
elif config.get("streaming") is not None:
135-
streaming = config["streaming"]
136-
if streaming.get("baseUri") is not None:
137-
opts["stream_uri"] = streaming["baseUri"]
138-
if streaming.get("filter") is not None:
139-
opts["payload_filter_key"] = streaming["filter"]
140-
_set_optional_time_prop(streaming, "initialRetryDelayMs", opts, "initial_reconnect_delay")
141-
elif config.get("polling") is not None:
142-
opts['stream'] = False
143-
polling = config["polling"]
144-
if polling.get("baseUri") is not None:
145-
opts["base_uri"] = polling["baseUri"]
146-
if polling.get("filter") is not None:
147-
opts["payload_filter_key"] = polling["filter"]
148-
_set_optional_time_prop(polling, "pollIntervalMs", opts, "poll_interval")
149-
elif not endpoints.get('streaming') and not endpoints.get('polling'):
150-
# No data source config and no streaming or polling endpoint means daemon mode.
151-
# A config that sets only an endpoint gets the default streaming data source.
152-
opts['use_ldd'] = True
153-
154134
if config.get("events") is not None:
155135
events = config["events"]
156136
opts["enable_event_compression"] = events.get("enableGzip", False)
@@ -179,9 +159,6 @@ def __init__(self, tag, config):
179159
_set_optional_time_prop(big_params, "staleAfterMs", big_config, "stale_after")
180160
opts["big_segments"] = BigSegmentsConfig(**big_config)
181161

182-
if config.get("persistentDataStore") is not None:
183-
opts["feature_store"] = _create_persistent_store(config["persistentDataStore"])
184-
185162
start_wait = config.get("startWaitTimeMs") or 5000
186163
config = Config(**opts)
187164

‎contract-tests/service.py‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def status():
6565
'all-flags-details-only-for-tracked-flags',
6666
'big-segments',
6767
'context-type',
68-
'filtering',
6968
'secure-mode-hash',
7069
'tags',
7170
'migrations',
@@ -86,8 +85,6 @@ def status():
8685
'flag-change-listeners',
8786
'flag-value-change-listeners',
8887
'fdv1-fallback',
89-
'retry-conformance-fdv1-streaming',
90-
'retry-conformance-fdv1-polling',
9188
'service-endpoints',
9289
'wrapper',
9390
'http-proxy',

‎docs/api-testing.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Test fixtures
22
=============
33

4-
ldclient.integrations.test_data module
5-
--------------------------------------
4+
ldclient.integrations.test_datav2 module
5+
----------------------------------------
66

7-
The entry point for this feature is :class:`ldclient.integrations.test_data.TestData`.
7+
The entry point for this feature is :class:`ldclient.integrations.test_datav2.TestDataV2`.
88

9-
.. automodule:: ldclient.integrations.test_data
9+
.. automodule:: ldclient.integrations.test_datav2
1010
:members:
1111
:special-members: __init__
1212
:show-inheritance:

‎ldclient/async_client.py‎

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from typing import Any, Callable, List, Optional, Tuple
88
from uuid import uuid4
99

10-
from ldclient.async_config import AsyncConfig
11-
from ldclient.async_feature_store import AsyncInMemoryFeatureStore
10+
from ldclient import async_datasystem
11+
from ldclient.async_config import AsyncConfig, AsyncDataSystemConfig
1212
from ldclient.context import Context
1313
from ldclient.evaluation import EvaluationDetail, FeatureFlagsState
1414
from ldclient.hook import (
@@ -52,6 +52,18 @@
5252
from ldclient.versioned_data_kind import FEATURES, SEGMENTS
5353

5454

55+
def _is_daemon_mode(datasystem_config: AsyncDataSystemConfig) -> bool:
56+
"""
57+
Return true if the data system has a persistent store and no data sources. The SDK then reads
58+
flags only from the store, which another process such as the Relay Proxy keeps up to date.
59+
"""
60+
return _has_no_data_sources(datasystem_config) and datasystem_config.data_store is not None
61+
62+
63+
def _has_no_data_sources(datasystem_config: AsyncDataSystemConfig) -> bool:
64+
return not datasystem_config.initializers and not datasystem_config.synchronizers
65+
66+
5567
class AsyncLDClient:
5668
"""Async LaunchDarkly SDK client.
5769
@@ -76,6 +88,7 @@ def __init__(self, config: AsyncConfig):
7688

7789
self._config = config
7890
self._config._instance_id = str(uuid4())
91+
self._datasystem_config = config.datasystem_config or async_datasystem.default().build()
7992
self._lifecycle_lock = asyncio.Lock()
8093

8194
self._started = False
@@ -202,17 +215,17 @@ async def __start_up(self, start_wait: float):
202215
# Start the big-segment status poll now that a loop is running.
203216
self.__big_segment_store_manager.start()
204217

205-
# FDv2 builds its data sources from builders; wire the shared session into
206-
# them before starting (FDv1 pulls the session itself via its provider).
207-
datasystem_config = self._config.datasystem_config
208-
if datasystem_config is not None and not self._config.offline:
209-
self._wire_data_source_sessions(datasystem_config)
218+
# The data system builds its data sources from builders. Give the shared
219+
# session to the builders before the data system starts.
220+
if not self._config.offline:
221+
self._wire_data_source_sessions(self._datasystem_config)
210222

211223
if self._config.offline:
212224
log.info("Started LaunchDarkly Client in offline mode")
213-
214-
if self._config.use_ldd:
215-
log.info("Started LaunchDarkly Client in LDD mode")
225+
elif _is_daemon_mode(self._datasystem_config):
226+
log.info("Started LaunchDarkly Client in daemon mode")
227+
elif _has_no_data_sources(self._datasystem_config):
228+
log.warning("The data system has no data sources and no persistent store. All evaluations will return default values.")
216229

217230
diagnostic_accumulator = self._set_event_processor(self._config)
218231

@@ -224,7 +237,7 @@ async def __start_up(self, start_wait: float):
224237
update_processor_ready = AsyncEvent()
225238
self._data_system.start(update_processor_ready)
226239

227-
if not self._config.offline and not self._config.use_ldd:
240+
if not self._config.offline and not _is_daemon_mode(self._datasystem_config):
228241
if start_wait > 60:
229242
log.warning(f"Client was configured to block for up to {start_wait} seconds when initializing. We recommend blocking no longer than 60.")
230243

@@ -239,7 +252,7 @@ async def __start_up(self, start_wait: float):
239252

240253
def _get_session(self):
241254
"""Return the shared aiohttp session, creating it on first use inside the
242-
event loop. Nothing creates it in offline/LDD mode, because no network
255+
event loop. Nothing creates it in offline or daemon mode, because no network
243256
component asks for it. Uses the same factory as the async transport so
244257
SSL/cert setup and proxy handling stay consistent (proxies are resolved
245258
per request, so the session itself has trust_env=False)."""
@@ -248,23 +261,9 @@ def _get_session(self):
248261
return self._session
249262

250263
def _make_data_system(self) -> AsyncDataSystem:
251-
datasystem_config = self._config.datasystem_config
252-
if datasystem_config is None:
253-
from ldclient.impl.datasystem.async_fdv1 import AsyncFDv1
254-
255-
return AsyncFDv1(self._config, self._select_feature_store(), self._get_session)
256-
257264
from ldclient.impl.datasystem.async_fdv2 import AsyncFDv2
258265

259-
return AsyncFDv2(self._config, datasystem_config)
260-
261-
def _select_feature_store(self) -> AsyncFeatureStore:
262-
"""Choose the async feature store for the v1 data system based on the
263-
configured store."""
264-
feature_store = self._config.feature_store
265-
if feature_store is None:
266-
return AsyncInMemoryFeatureStore()
267-
return feature_store
266+
return AsyncFDv2(self._config, self._datasystem_config)
268267

269268
def _wire_data_source_sessions(self, data_system_config) -> None:
270269
"""Provide the client's aiohttp session to any async data source
@@ -394,7 +393,7 @@ async def is_initialized(self) -> bool:
394393
395394
This is a coroutine because determining readiness may query a persistent store.
396395
"""
397-
if self.is_offline() or self._config.use_ldd:
396+
if self.is_offline():
398397
return True
399398

400399
return (await self._data_system.data_availability()).at_least(DataAvailability.CACHED)
@@ -499,7 +498,7 @@ async def _evaluate_internal(self, key: str, context: Context, default: Any, eve
499498
return EvaluationDetail(default, None, error_reason('CLIENT_NOT_READY')), None
500499

501500
availability = await self._data_system.data_availability()
502-
if availability != DataAvailability.REFRESHED:
501+
if not availability.at_least(self._data_system.target_availability):
503502
if availability == DataAvailability.CACHED:
504503
if not self._eval_cached_data_warned:
505504
self._eval_cached_data_warned = True
@@ -573,7 +572,7 @@ async def all_flags_state(self, context: Context, **kwargs) -> FeatureFlagsState
573572
return FeatureFlagsState(False)
574573

575574
availability = await self._data_system.data_availability()
576-
if availability != DataAvailability.REFRESHED:
575+
if not availability.at_least(self._data_system.target_availability):
577576
if availability == DataAvailability.CACHED:
578577
if not self._all_flags_cached_data_warned:
579578
self._all_flags_cached_data_warned = True

0 commit comments

Comments
 (0)