cattle_grid.account.router
cattle_grid.account.router
The exchanges used by cattle_grid are using routing keys to make processing easier. The cattle_grid gateway takes these messages and readdresses them with routing keys based on an user. Here an user can have multiple actors.
Furthermore, convenience methods are provided to manage users and actors through a HTTP Api. This is in difference to interacting with the Fediverse, which is done through a message queue.
create_gateway_router
create_gateway_router() -> RabbitRouter
Creates a router that moves messages to be routed by user.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
|
required |
Returns:
Type | Description |
---|---|
RabbitRouter
|
|
Source code in cattle_grid/account/router/__init__.py
annotations
AccountFromRoutingKey
module-attribute
Returns the account from the routing key
AccountName
module-attribute
AccountName = Annotated[str, Depends(name_from_routing_key)]
Assigns the account name extracted from the routing key
ActorForAccountFromMessage
module-attribute
ActorForAccountFromMessage = Annotated[
ActorForAccount, Depends(actor_for_account_from_account)
]
The actor provided in the send message
ActorFromMessage
module-attribute
The actor provided in the send message
MethodFromRoutingKey
module-attribute
MethodFromRoutingKey = Annotated[
str, Depends(method_from_routing_key)
]
Returns the method of a trigger message
RoutingKey
module-attribute
The AMQP routing key
method_from_routing_key
method_from_routing_key(
name: AccountName, routing_key: RoutingKey
) -> str
Extracts the method from the routing key
Source code in cattle_grid/account/router/annotations.py
name_from_routing_key
name_from_routing_key(routing_key: RoutingKey) -> str
router
create_actor_handler
async
create_actor_handler(
create_message: CreateActorRequest,
correlation_id: CorrelationId,
account: AccountFromRoutingKey,
broker: RabbitBroker = Context(),
) -> None
Creates an actor associated with the account.
Updating and deleting actors is done through trigger events.
Source code in cattle_grid/account/router/router.py
handle_fetch
async
handle_fetch(
msg: FetchMessage,
correlation_id: CorrelationId,
name: AccountName,
actor: ActorFromMessage,
broker: RabbitBroker = Context(),
)
Used to retrieve an object
Source code in cattle_grid/account/router/router.py
schema
get_async_api_schema
get_async_api_schema() -> Schema
Returns the async api schema for cattle_grid Account processing
get_mock_faststream_app
get_mock_faststream_app() -> FastStream
Creates a mock faststream app for Account processing
Source code in cattle_grid/account/router/schema.py
trigger
handle_trigger
async
handle_trigger(
msg: TriggerMessage,
actor: ActorForAccountFromMessage,
correlation_id: CorrelationId,
method: MethodFromRoutingKey,
broker: RabbitBroker = Context(),
)
Used to trigger a method performed by the actor.
The main thing an actor can do is send activities to
the Fediverse. This can be done with send_message
.
This can be extended in cattle_grid through extensions.
However the methods to update the actor profile and delete the actor are also called via a trigger.