utils
utils
¶
Shared utility functions for BigBrotr services.
Provides lightweight helpers used across multiple services. Domain-specific
logic belongs in per-service utils.py modules; only truly shared
primitives live here.
See Also
configs: Shared Pydantic network configuration models. queries: Centralized SQL query functions. mixins: Reusable service mixin classes.
Classes¶
Functions¶
parse_relay_url
¶
parse_relay_url(url: str) -> Relay | None
Parse a relay URL string into a Relay object.
Strips whitespace, rejects empty/non-string input, and delegates to the Relay constructor for RFC 3986 validation and network detection.
Parameters:
-
url(str) –Potential relay URL string.
Returns:
Source code in src/bigbrotr/services/common/utils.py
parse_delete_result
¶
Extract the row count from a PostgreSQL DELETE command status string.
PostgreSQL returns status strings like 'DELETE 42' from DELETE
commands. This function extracts the trailing integer count.
Parameters:
-
result(str | None) –The command status string (e.g.,
'DELETE 42'), orNoneif the command returned no status.
Returns:
-
int–Number of rows affected, or
0if parsing fails.