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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: message-db-py
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: The Python interface to the MessageDB Event Store and Message Store
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "message-db-py"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "The Python interface to the MessageDB Event Store and Message Store"
5
5
  authors = ["Subhash Bhushan <subhash.bhushan@gmail.com>"]
6
6
  license = "MIT"
@@ -1,3 +1,3 @@
1
- __version__ = "0.3.0"
1
+ __version__ = "0.3.2"
2
2
 
3
3
  # Re-export client class
@@ -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