cattle_grid.account.processing¶
cattle_grid.account.processing ¶
The exchanges used by cattle_grid are using routing keys to make processing easier. On the cattle_ground account router messages are also addressed by account. An account consists of a grouping of multiple actors.
create_account_router ¶
create_account_router() -> RabbitRouter
annotations ¶
AccountFromRoutingKey
module-attribute
¶
Returns the account 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
ResponderClass
dataclass
¶
ResponderClass(name: typing.Annotated[str, Dependant(name_from_routing_key)], publisher: Annotated[Callable, Dependant(AccountExchangePublisherClass)], reply_to: str | None = Context(required=True, cast=False))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
|
required |
publisher
|
Callable
|
|
required |
reply_to
|
str | None
|
|
Context(required=True, cast=False)
|
Source code in cattle_grid/account/processing/annotations.py
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/processing/annotations.py
history ¶
Handles creating the history for the actor
info ¶
cattle_drive_version ¶
router ¶
create_actor_handler
async
¶
create_actor_handler(
message: CreateActorRequest,
account: AccountFromRoutingKey,
session: CommittingSession,
responder: Responder,
)
Creates an actor associated with the account.
Updating and deleting actors is done through trigger events.
Source code in cattle_grid/account/processing/router.py
handle_fetch
async
¶
handle_fetch(
msg: FetchMessage,
actor: ActorFromMessage,
internal_requester: InternalExchangeRequester,
responder: Responder,
)
Used to retrieve an object
Source code in cattle_grid/account/processing/router.py
schema ¶
get_async_api_schema ¶
get_async_api_schema() -> AsyncAPI
Returns the async api schema for cattle_grid Account processing
Source code in cattle_grid/account/processing/schema.py
testing ¶
actor_with_account
async
¶
actor_with_account(sql_session, account_for_test) -> Actor
Fixture to create an actor with an account
Source code in cattle_grid/testing/fixtures.py
loaded_config ¶
sql_engine_for_tests
async
¶
Provides the sql engine (as in memory sqlite) for tests
This fixture has autouse=True, meaning that by importing
it will run automatically. The engine is initialized in the place cattle_grid expects it.
Source code in cattle_grid/testing/fixtures.py
sql_session
async
¶
Returns an AsyncSession to be used by tests
trigger ¶
handle_trigger
async
¶
handle_trigger(
msg: TriggerMessage,
actor: ActorForAccountFromMessage,
method: MethodFromRoutingKey,
session: SqlSession,
rewrite_rules: RewriteRules,
publisher: ActivityExchangePublisher,
)
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.