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(uid: EntityId) -> None
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
heartbeat_status
async
¶
Get the last heartbeat timestamp for a mailbox.
Source code in academy/exchange/cloud/backend.py
agent_stats
async
¶
agent_stats(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
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 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 | |
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(uid: EntityId) -> None
Update the heartbeat timestamp for a mailbox.
Source code in academy/exchange/cloud/backend.py
heartbeat_status
async
¶
Get the time since last heartbeat timestamp for a mailbox.
Source code in academy/exchange/cloud/backend.py
agent_stats
async
¶
agent_stats(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
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | |
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.