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
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
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 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 | |
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
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
1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 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 | |
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.