Skip to content

cattle_grid.tools.dependencies

This package include dependencies meant to be used outside of a cattle_grid context. Dependencies defined in cattle_grid.dependencies require a cattle_grid context, e.g. you are writing a cattle_grid extension.

AccountName module-attribute

AccountName = Annotated[str, Depends(name_from_routing_key)]

Assigns the account name extracted from the routing key

AccountPublisher module-attribute

AccountPublisher = Annotated[
    Callable, Depends(AccountPublisherClass)
]

When processing on the AccountExchange, allows one to publish a message as the current account. Usage

async def my_method(publisher: AccountPublisher):
    await publisher("trigger.publish_activity", {
        "actor": "http://local.example/actor/id",
        "data": {
            "type": "Activity",
            "actor": "http://local.example/actor/id",
        }
    })

ActorId module-attribute

ActorId = Annotated[str, Depends(actor_id)]

ActorId of the actor processing the message

CurrentExchange module-attribute

CurrentExchange = Annotated[
    RabbitExchange, Depends(current_exchange)
]

Returns the exchange the message was received on

RoutingKey module-attribute

RoutingKey = Annotated[
    str, Context("message.raw_message.routing_key")
]

The AMQP routing key