message-db-py 0.3.0__tar.gz → 0.3.2__tar.gz
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.
- {message_db_py-0.3.0 → message_db_py-0.3.2}/PKG-INFO +1 -1
- {message_db_py-0.3.0 → message_db_py-0.3.2}/pyproject.toml +1 -1
- {message_db_py-0.3.0 → message_db_py-0.3.2}/src/message_db/__init__.py +1 -1
- {message_db_py-0.3.0 → message_db_py-0.3.2}/src/message_db/client.py +45 -0
- {message_db_py-0.3.0 → message_db_py-0.3.2}/LICENSE +0 -0
- {message_db_py-0.3.0 → message_db_py-0.3.2}/README.md +0 -0
- {message_db_py-0.3.0 → message_db_py-0.3.2}/src/message_db/connection.py +0 -0
|
@@ -283,6 +283,51 @@ class MessageDB:
|
|
|
283
283
|
consumer_group_size=consumer_group_size,
|
|
284
284
|
)
|
|
285
285
|
|
|
286
|
+
def stream_identifiers(self, category_name: str) -> List[str]:
|
|
287
|
+
"""Return all unique aggregate identifiers for a stream category.
|
|
288
|
+
|
|
289
|
+
Extracts distinct identifiers from stream names matching the given
|
|
290
|
+
category, excluding snapshot streams. Stream names follow the pattern
|
|
291
|
+
``{category}-{identifier}``; snapshot streams use
|
|
292
|
+
``{category}:snapshot-{identifier}``.
|
|
293
|
+
|
|
294
|
+
Args:
|
|
295
|
+
category_name: The stream category (must not contain a hyphen).
|
|
296
|
+
|
|
297
|
+
Returns:
|
|
298
|
+
Sorted list of unique aggregate identifiers.
|
|
299
|
+
|
|
300
|
+
Raises:
|
|
301
|
+
ValueError: If *category_name* contains a hyphen.
|
|
302
|
+
"""
|
|
303
|
+
if "-" in category_name:
|
|
304
|
+
raise ValueError(f"{category_name} is not a category")
|
|
305
|
+
|
|
306
|
+
conn = self.connection_pool.get_connection()
|
|
307
|
+
cursor = conn.cursor()
|
|
308
|
+
|
|
309
|
+
cursor.execute(
|
|
310
|
+
"""
|
|
311
|
+
SELECT DISTINCT
|
|
312
|
+
substring(stream_name from position('-' in stream_name) + 1)
|
|
313
|
+
FROM message_store.messages
|
|
314
|
+
WHERE stream_name LIKE %(pattern)s
|
|
315
|
+
AND stream_name NOT LIKE %(snapshot_pattern)s
|
|
316
|
+
ORDER BY 1
|
|
317
|
+
""",
|
|
318
|
+
{
|
|
319
|
+
"pattern": f"{category_name}-%",
|
|
320
|
+
"snapshot_pattern": f"{category_name}:snapshot-%",
|
|
321
|
+
},
|
|
322
|
+
)
|
|
323
|
+
identifiers = [row[0] for row in cursor.fetchall() if row[0]]
|
|
324
|
+
|
|
325
|
+
conn.commit()
|
|
326
|
+
cursor.close()
|
|
327
|
+
self.connection_pool.release(conn)
|
|
328
|
+
|
|
329
|
+
return identifiers
|
|
330
|
+
|
|
286
331
|
def read_last_message(self, stream_name: str) -> Dict[str, Any] | None:
|
|
287
332
|
"""Read the last message from a stream."""
|
|
288
333
|
conn = self.connection_pool.get_connection()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|