Skip to content

Commit e98b75a

Browse files
committed
chore: Reorganize import structure to align with compatibility expectations
1 parent c5f30bc commit e98b75a

25 files changed

+861
-883
lines changed

ldclient/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from ldclient.feature_store import InMemoryFeatureStore
1212
from ldclient.hook import Hook
13-
from ldclient.impl.datasystem import Initializer, Synchronizer
1413
from ldclient.impl.util import (
1514
log,
1615
validate_application_info,
@@ -22,6 +21,8 @@
2221
DataStoreMode,
2322
EventProcessor,
2423
FeatureStore,
24+
Initializer,
25+
Synchronizer,
2526
UpdateProcessor
2627
)
2728
from ldclient.plugin import Plugin
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
StreamingDataSource,
1717
StreamingDataSourceBuilder
1818
)
19-
from ldclient.impl.datasystem import Initializer, Synchronizer
20-
from ldclient.interfaces import DataStoreMode, FeatureStore
19+
from ldclient.interfaces import (
20+
DataStoreMode,
21+
FeatureStore,
22+
Initializer,
23+
Synchronizer
24+
)
2125

2226
T = TypeVar("T")
2327

@@ -92,7 +96,7 @@ def build(self) -> DataSystemConfig:
9296
)
9397

9498

95-
def polling_ds_builder() -> Builder[PollingDataSource]:
99+
def __polling_ds_builder() -> Builder[PollingDataSource]:
96100
def builder(config: LDConfig) -> PollingDataSource:
97101
requester = Urllib3PollingRequester(config)
98102
polling_ds = PollingDataSourceBuilder(config)
@@ -103,7 +107,7 @@ def builder(config: LDConfig) -> PollingDataSource:
103107
return builder
104108

105109

106-
def fdv1_fallback_ds_builder() -> Builder[PollingDataSource]:
110+
def __fdv1_fallback_ds_builder() -> Builder[PollingDataSource]:
107111
def builder(config: LDConfig) -> PollingDataSource:
108112
requester = Urllib3FDv1PollingRequester(config)
109113
polling_ds = PollingDataSourceBuilder(config)
@@ -114,7 +118,7 @@ def builder(config: LDConfig) -> PollingDataSource:
114118
return builder
115119

116120

117-
def streaming_ds_builder() -> Builder[StreamingDataSource]:
121+
def __streaming_ds_builder() -> Builder[StreamingDataSource]:
118122
def builder(config: LDConfig) -> StreamingDataSource:
119123
return StreamingDataSourceBuilder(config).build()
120124

@@ -135,9 +139,9 @@ def default() -> ConfigBuilder:
135139
for updates.
136140
"""
137141

138-
polling_builder = polling_ds_builder()
139-
streaming_builder = streaming_ds_builder()
140-
fallback = fdv1_fallback_ds_builder()
142+
polling_builder = __polling_ds_builder()
143+
streaming_builder = __streaming_ds_builder()
144+
fallback = __fdv1_fallback_ds_builder()
141145

142146
builder = ConfigBuilder()
143147
builder.initializers([polling_builder])
@@ -154,8 +158,8 @@ def streaming() -> ConfigBuilder:
154158
with no additional latency.
155159
"""
156160

157-
streaming_builder = streaming_ds_builder()
158-
fallback = fdv1_fallback_ds_builder()
161+
streaming_builder = __streaming_ds_builder()
162+
fallback = __fdv1_fallback_ds_builder()
159163

160164
builder = ConfigBuilder()
161165
builder.synchronizers(streaming_builder)
@@ -171,8 +175,8 @@ def polling() -> ConfigBuilder:
171175
streaming, but may be necessary in some network environments.
172176
"""
173177

174-
polling_builder: Builder[Synchronizer] = polling_ds_builder()
175-
fallback = fdv1_fallback_ds_builder()
178+
polling_builder: Builder[Synchronizer] = __polling_ds_builder()
179+
fallback = __fdv1_fallback_ds_builder()
176180

177181
builder = ConfigBuilder()
178182
builder.synchronizers(polling_builder)
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
This module houses FDv2 types and implementations of synchronizers and
3-
initializers for the datasystem.
2+
This module houses FDv2 implementations of synchronizers and initializers for
3+
the datasystem.
44
55
All types and implementations in this module are considered internal
66
and are not part of the public API of the LaunchDarkly Python SDK.
@@ -9,7 +9,3 @@
99
1010
You have been warned.
1111
"""
12-
13-
from .polling import PollingResult, Requester
14-
15-
__all__: list[str] = ["PollingResult", "Requester"]

ldclient/impl/datasourcev2/polling.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,10 @@
1515

1616
from ldclient.config import Config
1717
from ldclient.impl.datasource.feature_requester import LATEST_ALL_URI
18-
from ldclient.impl.datasystem import BasisResult, SelectorStore, Update
1918
from ldclient.impl.datasystem.protocolv2 import (
20-
Basis,
21-
ChangeSet,
22-
ChangeSetBuilder,
2319
DeleteObject,
2420
EventName,
25-
IntentCode,
26-
ObjectKind,
27-
Payload,
28-
PutObject,
29-
Selector,
30-
ServerIntent
21+
PutObject
3122
)
3223
from ldclient.impl.http import _http_factory
3324
from ldclient.impl.repeating_task import RepeatingTask
@@ -44,11 +35,22 @@
4435
log
4536
)
4637
from ldclient.interfaces import (
38+
Basis,
39+
BasisResult,
40+
ChangeSet,
41+
ChangeSetBuilder,
4742
DataSourceErrorInfo,
4843
DataSourceErrorKind,
49-
DataSourceState
44+
DataSourceState,
45+
Initializer,
46+
IntentCode,
47+
ObjectKind,
48+
Selector,
49+
SelectorStore,
50+
ServerIntent,
51+
Synchronizer,
52+
Update
5053
)
51-
from ldclient.versioned_data_kind import FEATURES, SEGMENTS
5254

5355
POLLING_ENDPOINT = "/sdk/poll"
5456

@@ -78,7 +80,7 @@ def fetch(self, selector: Optional[Selector]) -> PollingResult:
7880
CacheEntry = namedtuple("CacheEntry", ["data", "etag"])
7981

8082

81-
class PollingDataSource:
83+
class PollingDataSource(Initializer, Synchronizer):
8284
"""
8385
PollingDataSource is a data source that can retrieve information from
8486
LaunchDarkly either as an Initializer or as a Synchronizer.
@@ -235,7 +237,7 @@ def _poll(self, ss: SelectorStore) -> BasisResult:
235237

236238

237239
# pylint: disable=too-few-public-methods
238-
class Urllib3PollingRequester:
240+
class Urllib3PollingRequester(Requester):
239241
"""
240242
Urllib3PollingRequester is a Requester that uses urllib3 to make HTTP
241243
requests.
@@ -401,7 +403,7 @@ def build(self) -> PollingDataSource:
401403

402404

403405
# pylint: disable=too-few-public-methods
404-
class Urllib3FDv1PollingRequester:
406+
class Urllib3FDv1PollingRequester(Requester):
405407
"""
406408
Urllib3PollingRequesterFDv1 is a Requester that uses urllib3 to make HTTP
407409
requests.

ldclient/impl/datasourcev2/status.py

Lines changed: 0 additions & 109 deletions
This file was deleted.

ldclient/impl/datasourcev2/streaming.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,13 @@
1818
from ld_eventsource.errors import HTTPStatusError
1919

2020
from ldclient.config import Config
21-
from ldclient.impl.datasystem import (
22-
DiagnosticAccumulator,
23-
DiagnosticSource,
24-
SelectorStore,
25-
Synchronizer,
26-
Update
27-
)
21+
from ldclient.impl.datasystem import DiagnosticAccumulator, DiagnosticSource
2822
from ldclient.impl.datasystem.protocolv2 import (
29-
ChangeSetBuilder,
3023
DeleteObject,
3124
Error,
3225
EventName,
3326
Goodbye,
34-
IntentCode,
35-
PutObject,
36-
Selector,
37-
ServerIntent
27+
PutObject
3828
)
3929
from ldclient.impl.http import HTTPFactory, _http_factory
4030
from ldclient.impl.util import (
@@ -45,9 +35,16 @@
4535
log
4636
)
4737
from ldclient.interfaces import (
38+
ChangeSetBuilder,
4839
DataSourceErrorInfo,
4940
DataSourceErrorKind,
50-
DataSourceState
41+
DataSourceState,
42+
IntentCode,
43+
Selector,
44+
SelectorStore,
45+
ServerIntent,
46+
Synchronizer,
47+
Update
5148
)
5249

5350
# allows for up to 5 minutes to elapse without any data sent across the stream.

0 commit comments

Comments
 (0)