academy.exchange.cloud.backend¶
MailboxBackend
¶
Bases: Protocol
Backend protocol for storing mailboxes on server.
check_mailbox
async
¶
check_mailbox(
client: ClientInfo, uid: EntityId
) -> MailboxStatus
Check if a mailbox exists, or is terminated.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to check.
Returns:
-
MailboxStatus–The mailbox status.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
create_mailbox
async
¶
create_mailbox(
client: ClientInfo,
uid: EntityId,
agent: tuple[str, ...] | None = None,
) -> None
Create a mailbox is not exists.
This method should be idempotent.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to check.
-
agent(tuple[str, ...] | None, default:None) –The agent_mro for behavior discovery.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
terminate
async
¶
terminate(client: ClientInfo, uid: EntityId) -> None
Close a mailbox.
For security, the manager should keep a gravestone so the same id cannot be re-registered.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to close.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
discover
async
¶
Find mailboxes of matching agent class.
Parameters:
-
client(ClientInfo) –Client making the request.
-
agent(str) –Agent class to search for.
-
allow_subclasses(bool) –Include agents that inherit from the target.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
get
async
¶
get(
client: ClientInfo,
uid: EntityId,
*,
timeout: float | None = None
) -> Message[Any]
Get messages from a mailbox.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to get messages.
-
timeout(float | None, default:None) –Time in seconds to wait for message. If None, wait indefinitely.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
-
TimeoutError–There was not message received during the timeout.
Source code in academy/exchange/cloud/backend.py
put
async
¶
put(client: ClientInfo, message: Message[Any]) -> None
Put a message in a mailbox.
Parameters:
-
client(ClientInfo) –Client making the request.
-
message(Message[Any]) –Message to put in mailbox.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
-
MessageTooLargeError–The message is larger than the message size limit for this exchange.
Source code in academy/exchange/cloud/backend.py
share_mailbox
async
¶
share_mailbox(
client: ClientInfo, uid: EntityId, group_uid: str
) -> None
Share a mailbox with a Globus Group.
Only the owner of the Mailbox is allowed to share with a Globus Group. This method should be idempotent.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to share.
-
group_uid(str) –Globus Group id to share.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox to share does not exist.
-
MailboxTerminatedError–The mailbox is closed.
Source code in academy/exchange/cloud/backend.py
get_mailbox_shares
async
¶
get_mailbox_shares(
client: ClientInfo, uid: EntityId
) -> list[str]
Get list of globus groups the mailbox is shared with.
Only the owner of the Mailbox is allowed to share with a Globus Group. This method should be idempotent.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to share.
Returns:
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
Source code in academy/exchange/cloud/backend.py
remove_mailbox_shares
async
¶
remove_mailbox_shares(
client: ClientInfo, uid: EntityId, group_uid: str
) -> None
Stop sharing a mailbox with a group.
Only the owner of the Mailbox is allowed to share with a Globus Group. This method should be idempotent (removing a group that the mailbox is not shared with is a no-op).
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to share.
-
group_uid(str) –Globus Group id to remove.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox to share does not exist.
-
MailboxTerminatedError–The mailbox is closed.
Source code in academy/exchange/cloud/backend.py
update_heartbeat
async
¶
update_heartbeat(client: ClientInfo, uid: EntityId) -> None
Update the heartbeat timestamp for a mailbox.
Parameters:
-
uid(EntityId) –Mailbox id to update.
-
client(ClientInfo) –Client Info to verify.
heartbeat_status
async
¶
heartbeat_status(
client: ClientInfo, uid: EntityId
) -> float | None
Get the last heartbeat timestamp of a mailbox.
Parameters:
-
uid(EntityId) –Mailbox id to check.
-
client(ClientInfo) –Client Info to verify.
Returns:
-
float | None–Unix timestamp of the last heartbeat, or None if never recorded.
Source code in academy/exchange/cloud/backend.py
agent_stats
async
¶
agent_stats(
client: ClientInfo, uid: EntityId
) -> AgentStats
Return live exchange-level metrics for an agent.
Parameters:
-
uid(EntityId) –Mailbox id to check.
-
client(ClientInfo) –Client Info to verify.
Source code in academy/exchange/cloud/backend.py
PythonBackend
¶
PythonBackend(message_size_limit_kb: int = 1024)
Mailbox backend using in-memory python data structures.
Parameters:
-
message_size_limit_kb(int, default:1024) –Maximum message size to allow.
Source code in academy/exchange/cloud/backend.py
check_mailbox
async
¶
check_mailbox(
client: ClientInfo, uid: EntityId
) -> MailboxStatus
Check if a mailbox exists, or is terminated.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to check.
Returns:
-
MailboxStatus–The mailbox status.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
create_mailbox
async
¶
create_mailbox(
client: ClientInfo,
uid: EntityId,
agent: tuple[str, ...] | None = None,
) -> None
Create a mailbox is not exists.
This method should be idempotent.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to check.
-
agent(tuple[str, ...] | None, default:None) –The agent_mro for behavior discovery.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
terminate
async
¶
terminate(client: ClientInfo, uid: EntityId) -> None
Close a mailbox.
For security, the manager should keep a gravestone so the same id cannot be re-registered.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to close.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
update_heartbeat
async
¶
update_heartbeat(client: ClientInfo, uid: EntityId) -> None
Update the heartbeat timestamp for a mailbox.
Source code in academy/exchange/cloud/backend.py
heartbeat_status
async
¶
heartbeat_status(
client: ClientInfo, uid: EntityId
) -> float | None
Get the last heartbeat timestamp for a mailbox.
Source code in academy/exchange/cloud/backend.py
agent_stats
async
¶
agent_stats(
client: ClientInfo, uid: EntityId
) -> AgentStats
Return live exchange-level metrics for an agent.
Source code in academy/exchange/cloud/backend.py
discover
async
¶
Find mailboxes of matching agent class.
Parameters:
-
client(ClientInfo) –Client making the request.
-
agent(str) –Agent class to search for.
-
allow_subclasses(bool) –Include agents that inherit from the target.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
get
async
¶
get(
client: ClientInfo,
uid: EntityId,
*,
timeout: float | None = None
) -> Message[Any]
Get messages from a mailbox.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to get messages.
-
timeout(float | None, default:None) –Time in seconds to wait for message. If None, wait indefinitely.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
-
TimeoutError–There was not message received during the timeout.
Source code in academy/exchange/cloud/backend.py
put
async
¶
put(client: ClientInfo, message: Message[Any]) -> None
Put a message in a mailbox.
Parameters:
-
client(ClientInfo) –Client making the request.
-
message(Message[Any]) –Message to put in mailbox.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
-
MessageTooLargeError–The message is larger than the message size limit for this exchange.
Source code in academy/exchange/cloud/backend.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | |
share_mailbox
async
¶
share_mailbox(
client: ClientInfo, uid: EntityId, group_uid: str
) -> None
Share a mailbox with a Globus group.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Target Mailbox for sharing
-
group_uid(str) –Group id to share mailbox with.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
get_mailbox_shares
async
¶
get_mailbox_shares(
client: ClientInfo, uid: EntityId
) -> list[str]
Get list of globus groups the mailbox is shared with.
Only the owner of the Mailbox is allowed to share with a Globus Group. This method should be idempotent.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to share.
Returns:
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
Source code in academy/exchange/cloud/backend.py
remove_mailbox_shares
async
¶
remove_mailbox_shares(
client: ClientInfo, uid: EntityId, group_uid: str
) -> None
Stop sharing a mailbox with a group.
Only the owner of the Mailbox is allowed to share with a Globus Group. This method should be idempotent (removing a group that the mailbox is not shared with is a no-op).
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to share.
-
group_uid(str) –Globus Group id to remove.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox to share does not exist.
-
MailboxTerminatedError–The mailbox is closed.
Source code in academy/exchange/cloud/backend.py
RedisBackend
¶
RedisBackend(
hostname: str = "localhost",
port: int = 6379,
*,
message_size_limit_kb: int = 1024,
kwargs: dict[str, Any] | None = None,
mailbox_expiration_s: int | None = None,
gravestone_expiration_s: int | None = None
)
Redis backend of mailboxes.
Parameters:
-
hostname(str, default:'localhost') –Host address of redis.
-
port(int, default:6379) –Redis port.
-
message_size_limit_kb(int, default:1024) –Maximum message size to allow.
-
kwargs(dict[str, Any] | None, default:None) –Addition arguments to pass to redis session.
Source code in academy/exchange/cloud/backend.py
check_mailbox
async
¶
check_mailbox(
client: ClientInfo, uid: EntityId
) -> MailboxStatus
Check if a mailbox exists, or is terminated.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to check.
Returns:
-
MailboxStatus–The mailbox status.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
create_mailbox
async
¶
create_mailbox(
client: ClientInfo,
uid: EntityId,
agent: tuple[str, ...] | None = None,
) -> None
Create a mailbox is not exists.
This method should be idempotent.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to check.
-
agent(tuple[str, ...] | None, default:None) –The agent_mro for behavior discovery.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
terminate
async
¶
terminate(client: ClientInfo, uid: EntityId) -> None
Close a mailbox.
For security, the manager should keep a gravestone so the same id cannot be re-registered.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to close.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
update_heartbeat
async
¶
update_heartbeat(client: ClientInfo, uid: EntityId) -> None
Update the heartbeat timestamp for a mailbox.
Source code in academy/exchange/cloud/backend.py
heartbeat_status
async
¶
heartbeat_status(
client: ClientInfo, uid: EntityId
) -> float | None
Get the time since last heartbeat timestamp for a mailbox.
Source code in academy/exchange/cloud/backend.py
agent_stats
async
¶
agent_stats(
client: ClientInfo, uid: EntityId
) -> AgentStats
Return live exchange-level metrics for an agent.
Source code in academy/exchange/cloud/backend.py
discover
async
¶
Find mailboxes of matching agent class.
Parameters:
-
client(ClientInfo) –Client making the request.
-
agent(str) –Agent class to search for.
-
allow_subclasses(bool) –Include agents that inherit from the target.
Source code in academy/exchange/cloud/backend.py
get
async
¶
get(
client: ClientInfo,
uid: EntityId,
*,
timeout: float | None = None
) -> Message[Any]
Get messages from a mailbox.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to get messages.
-
timeout(float | None, default:None) –Time in seconds to wait for message. If None, wait indefinitely.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
-
TimeoutError–There was not message received during the timeout.
Source code in academy/exchange/cloud/backend.py
put
async
¶
put(client: ClientInfo, message: Message[Any]) -> None
Put a message in a mailbox.
Parameters:
-
client(ClientInfo) –Client making the request.
-
message(Message[Any]) –Message to put in mailbox.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
-
MessageTooLargeError–The message is larger than the message size limit for this exchange.
Source code in academy/exchange/cloud/backend.py
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | |
share_mailbox
async
¶
share_mailbox(
client: ClientInfo, uid: EntityId, group_uid: str
) -> None
Share a mailbox with a Globus group.
Parameters:
-
client(ClientInfo) –Client making the request.
-
group_uid(str) –Group id to share mailbox with.
-
uid(EntityId) –Target Mailbox for sharing
Raises:
-
ForbiddenError–If the client does not have the right permissions.
Source code in academy/exchange/cloud/backend.py
get_mailbox_shares
async
¶
get_mailbox_shares(
client: ClientInfo, uid: EntityId
) -> list[str]
Get list of globus groups the mailbox is shared with.
Only the owner of the Mailbox is allowed to share with a Globus Group. This method should be idempotent.
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to share.
Returns:
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox requested does not exist.
-
MailboxTerminatedError–The mailbox is closed.
Source code in academy/exchange/cloud/backend.py
remove_mailbox_shares
async
¶
remove_mailbox_shares(
client: ClientInfo, uid: EntityId, group_uid: str
) -> None
Stop sharing a mailbox with a group.
Only the owner of the Mailbox is allowed to share with a Globus Group. This method should be idempotent (removing a group that the mailbox is not shared with is a no-op).
Parameters:
-
client(ClientInfo) –Client making the request.
-
uid(EntityId) –Mailbox id to share.
-
group_uid(str) –Globus Group id to remove.
Raises:
-
ForbiddenError–If the client does not have the right permissions.
-
BadEntityIdError–The mailbox to share does not exist.
-
MailboxTerminatedError–The mailbox is closed.