Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions contract-tests/client_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
Stage
)
from ldclient.config import BigSegmentsConfig
from ldclient.impl.datasourcev2.polling import PollingDataSourceBuilder
from ldclient.impl.datasystem.config import (
from ldclient.datasystem import (
custom,
fdv1_fallback_ds_builder,
polling_ds_builder,
streaming_ds_builder
)
from ldclient.impl.datasourcev2.polling import PollingDataSourceBuilder


class ClientEntity:
Expand Down Expand Up @@ -59,6 +60,7 @@ def __init__(self, tag, config):

primary_builder = None
secondary_builder = None
fallback_builder = None

if primary is not None:
streaming = primary.get('streaming')
Expand All @@ -74,6 +76,7 @@ def __init__(self, tag, config):
opts["base_uri"] = polling["baseUri"]
_set_optional_time_prop(polling, "pollIntervalMs", opts, "poll_interval")
primary_builder = polling_ds_builder()
fallback_builder = fdv1_fallback_ds_builder()

if secondary is not None:
streaming = secondary.get('streaming')
Expand All @@ -89,9 +92,12 @@ def __init__(self, tag, config):
opts["base_uri"] = polling["baseUri"]
_set_optional_time_prop(polling, "pollIntervalMs", opts, "poll_interval")
secondary_builder = polling_ds_builder()
fallback_builder = fdv1_fallback_ds_builder()

if primary_builder is not None:
datasystem.synchronizers(primary_builder, secondary_builder)
if fallback_builder is not None:
datasystem.fdv1_compatible_synchronizer(fallback_builder)

if datasystem_config.get("payloadFilter") is not None:
opts["payload_filter_key"] = datasystem_config["payloadFilter"]
Expand Down
3 changes: 2 additions & 1 deletion ldclient/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from ldclient.feature_store import InMemoryFeatureStore
from ldclient.hook import Hook
from ldclient.impl.datasystem import Initializer, Synchronizer
from ldclient.impl.util import (
log,
validate_application_info,
Expand All @@ -22,6 +21,8 @@
DataStoreMode,
EventProcessor,
FeatureStore,
Initializer,
Synchronizer,
UpdateProcessor
)
from ldclient.plugin import Plugin
Expand Down
8 changes: 6 additions & 2 deletions ldclient/impl/datasystem/config.py → ldclient/datasystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
StreamingDataSource,
StreamingDataSourceBuilder
)
from ldclient.impl.datasystem import Initializer, Synchronizer
from ldclient.interfaces import DataStoreMode, FeatureStore
from ldclient.interfaces import (
DataStoreMode,
FeatureStore,
Initializer,
Synchronizer
)

T = TypeVar("T")

Expand Down
8 changes: 2 additions & 6 deletions ldclient/impl/datasourcev2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This module houses FDv2 types and implementations of synchronizers and
initializers for the datasystem.
This module houses FDv2 implementations of synchronizers and initializers for
the datasystem.

All types and implementations in this module are considered internal
and are not part of the public API of the LaunchDarkly Python SDK.
Expand All @@ -9,7 +9,3 @@

You have been warned.
"""

from .polling import PollingResult, Requester

__all__: list[str] = ["PollingResult", "Requester"]
32 changes: 17 additions & 15 deletions ldclient/impl/datasourcev2/polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,10 @@

from ldclient.config import Config
from ldclient.impl.datasource.feature_requester import LATEST_ALL_URI
from ldclient.impl.datasystem import BasisResult, SelectorStore, Update
from ldclient.impl.datasystem.protocolv2 import (
Basis,
ChangeSet,
ChangeSetBuilder,
DeleteObject,
EventName,
IntentCode,
ObjectKind,
Payload,
PutObject,
Selector,
ServerIntent
PutObject
)
from ldclient.impl.http import _http_factory
from ldclient.impl.repeating_task import RepeatingTask
Expand All @@ -44,11 +35,22 @@
log
)
from ldclient.interfaces import (
Basis,
BasisResult,
ChangeSet,
ChangeSetBuilder,
DataSourceErrorInfo,
DataSourceErrorKind,
DataSourceState
DataSourceState,
Initializer,
IntentCode,
ObjectKind,
Selector,
SelectorStore,
ServerIntent,
Synchronizer,
Update
)
from ldclient.versioned_data_kind import FEATURES, SEGMENTS

POLLING_ENDPOINT = "/sdk/poll"

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


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


# pylint: disable=too-few-public-methods
class Urllib3PollingRequester:
class Urllib3PollingRequester(Requester):
"""
Urllib3PollingRequester is a Requester that uses urllib3 to make HTTP
requests.
Expand Down Expand Up @@ -401,7 +403,7 @@ def build(self) -> PollingDataSource:


# pylint: disable=too-few-public-methods
class Urllib3FDv1PollingRequester:
class Urllib3FDv1PollingRequester(Requester):
"""
Urllib3PollingRequesterFDv1 is a Requester that uses urllib3 to make HTTP
requests.
Expand Down
109 changes: 0 additions & 109 deletions ldclient/impl/datasourcev2/status.py

This file was deleted.

23 changes: 10 additions & 13 deletions ldclient/impl/datasourcev2/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,13 @@
from ld_eventsource.errors import HTTPStatusError

from ldclient.config import Config
from ldclient.impl.datasystem import (
DiagnosticAccumulator,
DiagnosticSource,
SelectorStore,
Synchronizer,
Update
)
from ldclient.impl.datasystem import DiagnosticAccumulator, DiagnosticSource
from ldclient.impl.datasystem.protocolv2 import (
ChangeSetBuilder,
DeleteObject,
Error,
EventName,
Goodbye,
IntentCode,
PutObject,
Selector,
ServerIntent
PutObject
)
from ldclient.impl.http import HTTPFactory, _http_factory
from ldclient.impl.util import (
Expand All @@ -45,9 +35,16 @@
log
)
from ldclient.interfaces import (
ChangeSetBuilder,
DataSourceErrorInfo,
DataSourceErrorKind,
DataSourceState
DataSourceState,
IntentCode,
Selector,
SelectorStore,
ServerIntent,
Synchronizer,
Update
)

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