nebu 0.1.20__py3-none-any.whl → 0.1.21__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nebu/processors/consumer.py +29 -7
- {nebu-0.1.20.dist-info → nebu-0.1.21.dist-info}/METADATA +1 -1
- {nebu-0.1.20.dist-info → nebu-0.1.21.dist-info}/RECORD +6 -6
- {nebu-0.1.20.dist-info → nebu-0.1.21.dist-info}/WHEEL +0 -0
- {nebu-0.1.20.dist-info → nebu-0.1.21.dist-info}/licenses/LICENSE +0 -0
- {nebu-0.1.20.dist-info → nebu-0.1.21.dist-info}/top_level.txt +0 -0
nebu/processors/consumer.py
CHANGED
@@ -6,7 +6,7 @@ import sys
|
|
6
6
|
import time
|
7
7
|
import traceback
|
8
8
|
from datetime import datetime
|
9
|
-
from typing import
|
9
|
+
from typing import Dict, TypeVar
|
10
10
|
|
11
11
|
import redis
|
12
12
|
import socks
|
@@ -246,6 +246,9 @@ except Exception as e:
|
|
246
246
|
|
247
247
|
# Create consumer group if it doesn't exist
|
248
248
|
try:
|
249
|
+
# Assert types before use
|
250
|
+
assert isinstance(REDIS_STREAM, str)
|
251
|
+
assert isinstance(REDIS_CONSUMER_GROUP, str)
|
249
252
|
r.xgroup_create(REDIS_STREAM, REDIS_CONSUMER_GROUP, id="0", mkstream=True)
|
250
253
|
print(f"Created consumer group {REDIS_CONSUMER_GROUP} for stream {REDIS_STREAM}")
|
251
254
|
except ResponseError as e:
|
@@ -262,14 +265,32 @@ def process_message(message_id: bytes, message_data: Dict[bytes, bytes]) -> None
|
|
262
265
|
return_stream = None
|
263
266
|
user_id = None
|
264
267
|
|
268
|
+
print(f"Message data inner: {message_data}")
|
269
|
+
|
265
270
|
try:
|
266
|
-
#
|
267
|
-
#
|
268
|
-
|
271
|
+
# Extract the JSON string payload from the b'data' field
|
272
|
+
# Redis keys/fields might be bytes even with decode_responses=True
|
273
|
+
payload_str = message_data.get(b"data")
|
274
|
+
|
275
|
+
# decode_responses=True should handle decoding, but Redis can be tricky.
|
276
|
+
# If errors persist, we might need to re-add explicit decode checks.
|
277
|
+
if not payload_str or not isinstance(payload_str, str):
|
278
|
+
# Add a more specific check if needed later based on runtime errors
|
279
|
+
raise ValueError(
|
280
|
+
f"Missing or invalid 'data' field (expected string): {message_data}"
|
281
|
+
)
|
269
282
|
|
270
|
-
#
|
271
|
-
|
272
|
-
|
283
|
+
# Parse the JSON string into a dictionary
|
284
|
+
try:
|
285
|
+
raw_payload = json.loads(payload_str)
|
286
|
+
except json.JSONDecodeError as json_err:
|
287
|
+
raise ValueError(f"Failed to parse JSON payload: {json_err}") from json_err
|
288
|
+
|
289
|
+
# Validate that raw_payload is a dictionary as expected
|
290
|
+
if not isinstance(raw_payload, dict):
|
291
|
+
raise TypeError(
|
292
|
+
f"Expected parsed payload to be a dictionary, but got {type(raw_payload)}"
|
293
|
+
)
|
273
294
|
|
274
295
|
print(f"Raw payload: {raw_payload}")
|
275
296
|
|
@@ -462,6 +483,7 @@ while True:
|
|
462
483
|
|
463
484
|
# Read from stream with blocking
|
464
485
|
streams = {REDIS_STREAM: ">"} # '>' means read only new messages
|
486
|
+
# The type checker still struggles here, but the runtime types are asserted.
|
465
487
|
messages = r.xreadgroup( # type: ignore[arg-type]
|
466
488
|
REDIS_CONSUMER_GROUP, consumer_name, streams, count=1, block=5000
|
467
489
|
)
|
@@ -6,15 +6,15 @@ nebu/containers/container.py,sha256=yb7KaPTVXnEEAlrpdlUi4HNqF6P7z9bmwAILGlq6iqU,
|
|
6
6
|
nebu/containers/decorator.py,sha256=uFtzlAXRHYZECJ-NPusY7oN9GXvdHrHDd_JNrIGr8aQ,3244
|
7
7
|
nebu/containers/models.py,sha256=0j6NGy4yto-enRDh_4JH_ZTbHrLdSpuMOqNQPnIrwC4,6815
|
8
8
|
nebu/containers/server.py,sha256=yFa2Y9PzBn59E1HftKiv0iapPonli2rbGAiU6r-wwe0,2513
|
9
|
-
nebu/processors/consumer.py,sha256=
|
9
|
+
nebu/processors/consumer.py,sha256=47ssdvJU7CGur0JoehNrmNGKwAAzVDVp7UTnphApQlI,20080
|
10
10
|
nebu/processors/decorate.py,sha256=AeG1c1n8JtcexxAEf2sF2L2eKwVDaNQ5gvPs6EpazKo,34789
|
11
11
|
nebu/processors/default.py,sha256=W4slJenG59rvyTlJ7gRp58eFfXcNOTT2Hfi6zzJAobI,365
|
12
12
|
nebu/processors/models.py,sha256=GvnI8UJrQSjHo2snP07cPfisCH90cEGTY-PZV5_AtXI,3654
|
13
13
|
nebu/processors/processor.py,sha256=oy2YdI-cy6qQWxrZhpZahJV46oWZlu_Im-jm811R_oo,9667
|
14
14
|
nebu/redis/models.py,sha256=coPovAcVXnOU1Xh_fpJL4PO3QctgK9nBe5QYoqEcnxg,1230
|
15
15
|
nebu/services/service.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
|
-
nebu-0.1.
|
17
|
-
nebu-0.1.
|
18
|
-
nebu-0.1.
|
19
|
-
nebu-0.1.
|
20
|
-
nebu-0.1.
|
16
|
+
nebu-0.1.21.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
17
|
+
nebu-0.1.21.dist-info/METADATA,sha256=SmlvWXJgnKLKph_8UCEtgVtLz80EuKrcxRNm3hdEl_8,1678
|
18
|
+
nebu-0.1.21.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
19
|
+
nebu-0.1.21.dist-info/top_level.txt,sha256=uLIbEKJeGSHWOAJN5S0i5XBGwybALlF9bYoB1UhdEgQ,5
|
20
|
+
nebu-0.1.21.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|