Skip to content

Commit b9fc62a

Browse files
authored
Merge pull request #58 from launchdarkly/dr/indirect
Fix indirect streaming messages.
2 parents c824b35 + 763ee42 commit b9fc62a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

ldclient/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get():
3434
global client
3535
_lock.lock()
3636
if not client:
37-
log.info("Initializing LaunchDarkly Client")
37+
log.info("Initializing LaunchDarkly Client " + version.VERSION)
3838
client = LDClient(sdk_key, config, start_wait)
3939
return client
4040
finally:

ldclient/feature_requester.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from ldclient.interfaces import FeatureRequester
77
from ldclient.util import _headers
8+
from ldclient.util import log
89

910

1011
class FeatureRequesterImpl(FeatureRequester):
@@ -16,6 +17,7 @@ def __init__(self, sdk_key, config):
1617
def get_all(self):
1718
hdrs = _headers(self._sdk_key)
1819
uri = self._config.get_latest_features_uri
20+
log.debug("Getting all flags using uri: " + uri)
1921
r = self._session.get(uri, headers=hdrs, timeout=(
2022
self._config.connect_timeout, self._config.read_timeout))
2123
r.raise_for_status()
@@ -25,6 +27,7 @@ def get_all(self):
2527
def get_one(self, key):
2628
hdrs = _headers(self._sdk_key)
2729
uri = self._config.get_latest_features_uri + '/' + key
30+
log.debug("Getting one feature flag using uri: " + uri)
2831
r = self._session.get(uri,
2932
headers=hdrs,
3033
timeout=(self._config.connect_timeout,

ldclient/streaming.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,28 @@ def initialized(self):
4646

4747
@staticmethod
4848
def process_message(store, requester, msg, ready):
49-
payload = json.loads(msg.data)
50-
log.debug("Received stream event {}".format(msg.event))
49+
log.debug("Received stream event {} with data: {}".format(msg.event, msg.data))
5150
if msg.event == 'put':
51+
payload = json.loads(msg.data)
5252
store.init(payload)
5353
if not ready.is_set() and store.initialized:
5454
log.info("StreamingUpdateProcessor initialized ok")
5555
return True
5656
elif msg.event == 'patch':
57+
payload = json.loads(msg.data)
5758
key = payload['path'][1:]
5859
feature = payload['data']
59-
log.debug("Updating feature {}".format(key))
6060
store.upsert(key, feature)
6161
elif msg.event == "indirect/patch":
62-
key = payload['data']
62+
key = msg.data
6363
store.upsert(key, requester.get_one(key))
6464
elif msg.event == "indirect/put":
6565
store.init(requester.get_all())
6666
if not ready.is_set() and store.initialized:
6767
log.info("StreamingUpdateProcessor initialized ok")
6868
return True
6969
elif msg.event == 'delete':
70+
payload = json.loads(msg.data)
7071
key = payload['path'][1:]
7172
# noinspection PyShadowingNames
7273
version = payload['version']

0 commit comments

Comments
 (0)