.exchange¶
cattle_grid.exchange ¶
create_router ¶
create_router(
main_exchange: RabbitExchange | None = None,
include_shovels=True,
) -> RabbitRouter
Creates a router to be used to manage users
Source code in cattle_grid/exchange/__init__.py
actor_update ¶
handle_actor_action
async
¶
handle_actor_action(
actor: Actor,
session: AsyncSession,
action: UpdateAction,
) -> bool
Handles individual actions from the UpdateActor method
Source code in cattle_grid/exchange/actor_update/__init__.py
identifiers ¶
handle_add_identifier
async
¶
handle_add_identifier(
actor: Actor,
session: AsyncSession,
action: UpdateIdentifierAction,
)
Adds an identifier to the actor
FIXME: Currently missing logic to verify identifier
Source code in cattle_grid/exchange/actor_update/identifiers.py
urls ¶
url_matches ¶
Checks if the item represents the url
>>> url_matches("http://remote.test", "http://remote.test")
True
>>> url_matches({"href": "http://remote.test"}, "http://remote.test")
True
Source code in cattle_grid/exchange/actor_update/urls.py
exception ¶
exception_handler
async
¶
exception_handler(
exception: Exception,
routing_key: RoutingKey,
session: SqlSession,
publisher: AccountExchangePublisher,
message=Context("message.body"),
)
When an exception occurs in processing, this handler will create
an appropriate entry in receive.NAME.error
in the account exchange
Source code in cattle_grid/exchange/exception.py
handlers ¶
delete_actor_handler
async
¶
delete_actor_handler(
message: DeleteActorMessage,
actor: MessageActor,
session: SqlSession,
publisher: InternalExchangePublisher,
) -> None
Deletes the actor by id. Should be used asynchronously.
Source code in cattle_grid/exchange/handlers.py
update_actor
async
¶
update_actor(
message: UpdateActorMessage,
actor: MessageActor,
session: SqlSession,
publisher: InternalExchangePublisher,
) -> None
Should be used asynchronously
Source code in cattle_grid/exchange/handlers.py
info ¶
exchange_method_information
module-attribute
¶
exchange_method_information = [
MethodInformationModel(
module="cattle_grid.exchange",
routing_key="send_message",
description="Takes an activity and sends it to its recipients",
),
MethodInformationModel(
module="cattle_grid.exchange",
routing_key="update_actor",
description="Updates an actor",
),
MethodInformationModel(
module="cattle_grid.exchange",
routing_key="delete_actor",
description="Deletes an actor",
),
]
Information about the methods defined on the ActivityExchange by default
add_method_information
async
¶
add_method_information(
message: AddMethodInformationMessage,
)
Adds information about methods defined by an extension
Source code in cattle_grid/exchange/info.py
message_handlers ¶
fetch
async
¶
fetch(
message: FetchMessage,
transformer: Transformer,
lookup: LookupAnnotation,
actor: MessageBovineActor,
) -> dict
Used to fetch an object as an RPC method. In difference to fetch_object
,
this method applies the transformer.
Source code in cattle_grid/exchange/message_handlers.py
fetch_object
async
¶
fetch_object(
msg: FetchMessage, requester: InternalExchangeRequester
) -> dict
Used to fetch an object as an RPC method
send_message
async
¶
send_message(
msg: ActivityMessage,
publisher: InternalExchangePublisher,
) -> None
Takes a message and ensure it is distributed appropriately
Source code in cattle_grid/exchange/message_handlers.py
shovel ¶
incoming_shovel
async
¶
incoming_shovel(
msg: ActivityMessage,
session: SqlSession,
transformer: Transformer,
publisher: ActivityExchangePublisher,
account_publisher: AccountExchangePublisher,
) -> None
Transfers the message from the RawExchange to the Activity- and Account one.
The message is passed through the transformer.
Source code in cattle_grid/exchange/shovel.py
should_shovel_activity
async
¶
should_shovel_activity(
session: AsyncSession, activity: dict
) -> bool
Some activities like Block or Undo Block should not be visible to the user. This method returns False if this is the case.