Skip to content

cattle_grid.dependencies.account

AccountName module-attribute

Assigns the account name extracted from the routing key

name_from_routing_key

name_from_routing_key(routing_key: RoutingKey) -> str
>>> name_from_routing_key("receiving.alice")
'alice'

>>> name_from_routing_key("receiving.alice.action.fetch")
'alice'
Source code in cattle_grid/dependencies/account.py
def name_from_routing_key(
    routing_key: RoutingKey,
) -> str:
    """
    ```pycon
    >>> name_from_routing_key("receiving.alice")
    'alice'

    >>> name_from_routing_key("receiving.alice.action.fetch")
    'alice'

    ```
    """
    return routing_key.split(".")[1]