-
Notifications
You must be signed in to change notification settings - Fork 130
feat: add turn admission hook #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| from republic import AsyncStreamEvents, AsyncTapeStore, TapeContext | ||
| from republic.tape import TapeStore | ||
|
|
||
| from bub.turn_admission import AdmitDecision, TurnSnapshot | ||
| from bub.types import Envelope, MessageHandler, State | ||
|
|
||
| if TYPE_CHECKING: | ||
|
|
@@ -107,3 +108,16 @@ def provide_channels(self, message_handler: MessageHandler) -> list[Channel]: | |
| def build_tape_context(self) -> TapeContext: | ||
| """Build a tape context for the current session, to be used to build context messages.""" | ||
| raise NotImplementedError | ||
|
|
||
| @hookspec(firstresult=True) | ||
| def admit_message( | ||
| self, | ||
| session_id: str, | ||
| message: Envelope, | ||
| turn: TurnSnapshot, | ||
| ) -> AdmitDecision | None: | ||
| """Decide how to handle an inbound channel message for a session. | ||
| Return ``None`` to keep Bub's default concurrent scheduling behavior. | ||
| """ | ||
| raise NotImplementedError | ||
|
Comment on lines
+112
to
+123
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better to implement this as a method of Channel? Because steering is highly related to channels, each channel should be able to define its own steering logic. The current approach only takes the first implemented hook.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this property used for and what is different between it and
message.session_id?