-
Notifications
You must be signed in to change notification settings - Fork 133
Initial broker design and implementation #880
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
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
6b1b897
broker design v0.1
wdcui 6259a2b
updated
wdcui b45215f
Document broker split design
wdcui 605c1c1
Document broker implementation plan
wdcui 4c7a391
Incorporate sandbox architecture findings
wdcui 76cd13f
Add split broker event POC
wdcui ec6163c
fix cargo lock
wdcui 551ca42
Decouple broker core from protocol layers
wdcui c90b69e
Hide foreign broker object references
wdcui 4845aa5
Harden split broker interfaces
wdcui fb982cc
Simplify broker object handles
wdcui f0fb824
Allow Unix broker transport in no_std CI
wdcui 3deef1c
Refine broker channel interfaces
wdcui 5965b0f
Prune broker unit tests
wdcui 717ac4b
Clean up split broker modularity
wdcui 8d1d5f0
Document split broker dependency boundaries
wdcui feafb8f
Address split broker review follow-ups
wdcui 00b6b30
Integrate split broker with linux userland runner
wdcui d12f7f8
Rename broker runner integration
wdcui 463396e
Keep broker startup negotiation-only
wdcui dc3c445
Clean up broker protocol and eventfd path
wdcui b68d9bb
Move broker boundary into local core
wdcui f7cc115
Hide event backend behind local core
wdcui 3118644
Clean up local core broker layering
wdcui a2e465a
Simplify broker event counter surface
wdcui 03b2764
Split local core broker adapters
wdcui bc82f18
Clean up broker event layering
wdcui 6da49ee
Simplify broker event adapter
wdcui c91bebd
Refine broker-backed event counter interface
wdcui f2f8034
Align event counter factory with event domain
wdcui 813550e
Simplify event counter local-core interface
wdcui e0641d4
Simplify eventfd shim integration
wdcui 3d49ca3
Restore shim pipe module
wdcui d2ec34c
Fix eventfd writev zero-length handling
wdcui 7b8bd9e
Prune redundant broker tests
wdcui f2c6154
Preserve generic writev handling
wdcui 738c871
Update broker design eventfd status
wdcui 9fe28ea
Address broker review followups
wdcui 5c03a0d
Rename broker adapter crates
wdcui 10f15ee
Merge broker wire into protocol
wdcui 09dbbed
Address broker interface review feedback
wdcui 663b7f6
Align broker terminology and control client API
wdcui 1f79af3
Rename broker event channel to notification channel
wdcui 70fa831
Refactor broker policy engine
wdcui 28ae7fb
Fix CI eventfd regressions
wdcui aacb196
Simplify broker identity model
wdcui 02f7d70
Update eventfd fcntl test expectation
wdcui 5d1cdf7
Restore eventfd fcntl test coverage
wdcui d702489
Avoid extra broker core test global
wdcui 6f310fe
Prune redundant broker tests
wdcui 6a520d1
Rename broker local and host errors
wdcui 4bc3077
Remove broker local worker
wdcui 83117fc
Align broker local and host naming
wdcui 45732e1
Fold broker negotiation modules into crate roots
wdcui 24529d7
Prune broker local and host tests
wdcui d5b0f49
Centralize initial broker protocol version
wdcui 2620a48
Organize broker wire codec by protocol layer
wdcui 4063b18
Prune Unix socket transport tests
wdcui 84e8588
Clean up broker local integration layering
wdcui 928acfa
Expand broker eventfd fixture coverage
wdcui fe92183
Assert broker eventfd traffic in runner test
wdcui 756edcd
Fix shim eventfd and vectored IO semantics
wdcui f0d9e07
Join epoll eventfd test writer thread
wdcui 5dcc8fd
Remove broker design docs from implementation PR
wdcui ea52efe
Back out non-eventfd vectored IO changes
wdcui e1d7407
Simplify eventfd fixture IO paths
wdcui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| use litebox_broker_protocol::ErrorCode; | ||
|
|
||
| use crate::event::{counter::EventCounterError, polling::TryOpError}; | ||
|
|
||
| /// Error returned by the deployment-provided broker control path. | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
| #[non_exhaustive] | ||
| pub enum BrokerControlError { | ||
| /// The broker control transport failed. | ||
| Transport, | ||
| /// The broker returned an operation error. | ||
| Broker(ErrorCode), | ||
| /// The broker returned a response shape that does not match the request. | ||
| UnexpectedResponse, | ||
| } | ||
|
|
||
| /// Internal normalized error for broker-backed object adapters. | ||
| /// | ||
| /// This keeps protocol/control-channel failures separate from the public | ||
| /// object-specific API error exposed by each local-core facade. | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
| pub(crate) enum BrokerObjectError { | ||
| /// The deployment-provided broker control path failed. | ||
| Control, | ||
| /// The broker rejected the cached object handle, type, or rights. | ||
| InvalidObject, | ||
| /// The object operation would block in its current broker-side state. | ||
| WouldBlock, | ||
| /// The object or broker-side state cannot grow further. | ||
| ResourceExhausted, | ||
| /// The broker returned a response shape that does not match the request. | ||
| UnexpectedResponse, | ||
| /// The broker reported a non-recoverable or unsupported object error. | ||
| Internal, | ||
| } | ||
|
|
||
| impl From<BrokerControlError> for BrokerObjectError { | ||
| fn from(error: BrokerControlError) -> Self { | ||
| match error { | ||
| BrokerControlError::Transport => Self::Control, | ||
| BrokerControlError::Broker(error) => error.into(), | ||
| BrokerControlError::UnexpectedResponse => Self::UnexpectedResponse, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl From<ErrorCode> for BrokerObjectError { | ||
| fn from(error: ErrorCode) -> Self { | ||
| match error { | ||
| ErrorCode::InvalidRights | ||
| | ErrorCode::UnknownObject | ||
| | ErrorCode::WrongObjectType | ||
| | ErrorCode::StaleHandle => Self::InvalidObject, | ||
| ErrorCode::WouldBlock => Self::WouldBlock, | ||
| ErrorCode::ResourceExhausted => Self::ResourceExhausted, | ||
| _ => Self::Internal, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub(crate) fn map_broker_object_result<T>( | ||
| result: Result<T, BrokerObjectError>, | ||
| ) -> Result<T, TryOpError<EventCounterError>> { | ||
| match result { | ||
| Ok(value) => Ok(value), | ||
| Err(BrokerObjectError::WouldBlock) => Err(TryOpError::TryAgain), | ||
| Err(error) => Err(TryOpError::Other(error.into())), | ||
| } | ||
| } | ||
|
|
||
| impl From<BrokerObjectError> for EventCounterError { | ||
| fn from(error: BrokerObjectError) -> Self { | ||
| match error { | ||
| BrokerObjectError::WouldBlock => Self::WouldBlock, | ||
| BrokerObjectError::ResourceExhausted => Self::ResourceExhausted, | ||
| BrokerObjectError::UnexpectedResponse => Self::UnexpectedResponse, | ||
| BrokerObjectError::Control | ||
| | BrokerObjectError::InvalidObject | ||
| | BrokerObjectError::Internal => Self::Io, | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT license. | ||
|
|
||
| use alloc::sync::Arc; | ||
|
|
||
| use litebox_broker_local::{BrokerLocal, BrokerLocalError}; | ||
| use litebox_broker_protocol::{CoreRequest, CoreResponse, LocalControlChannel}; | ||
|
|
||
| use crate::sync::{Mutex, RawSyncPrimitivesProvider}; | ||
|
|
||
| pub(crate) mod error; | ||
| pub use error::BrokerControlError; | ||
|
|
||
| /// Local-core access to the negotiated broker control channel. | ||
| /// | ||
| /// LiteBox owns broker-backed local objects and constructs broker protocol | ||
| /// requests. Deployment code owns endpoint selection and supplies the connected | ||
| /// transport behind this protocol-level boundary. | ||
| pub trait BrokerControl: Send + Sync { | ||
| /// Sends one active BrokerCore request and returns its response. | ||
| fn request( | ||
| &self, | ||
| request: CoreRequest, | ||
| ) -> core::result::Result<CoreResponse, BrokerControlError>; | ||
| } | ||
|
Comment on lines
+14
to
+25
Member
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. This interfaces forces a blocking design, should document that we want to move away from this, at minimum |
||
|
|
||
| struct BrokerLocalControl<Platform: RawSyncPrimitivesProvider, T> { | ||
| local: Mutex<Platform, BrokerLocal<T>>, | ||
| } | ||
|
|
||
| impl<Platform, T> BrokerLocalControl<Platform, T> | ||
| where | ||
| Platform: RawSyncPrimitivesProvider, | ||
| { | ||
| const fn new(local: BrokerLocal<T>) -> Self { | ||
| Self { | ||
| local: Mutex::new(local), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<Platform, T> BrokerControl for BrokerLocalControl<Platform, T> | ||
| where | ||
| Platform: RawSyncPrimitivesProvider, | ||
| T: LocalControlChannel + Send, | ||
| { | ||
| fn request( | ||
| &self, | ||
| request: CoreRequest, | ||
| ) -> core::result::Result<CoreResponse, BrokerControlError> { | ||
| self.local | ||
| .lock() | ||
| .active_core_request(request) | ||
| .map_err(broker_control_error) | ||
| } | ||
| } | ||
|
|
||
| fn broker_control_error<E>(error: BrokerLocalError<E>) -> BrokerControlError { | ||
| match error { | ||
| BrokerLocalError::Broker(error) => BrokerControlError::Broker(error), | ||
| BrokerLocalError::UnexpectedResponse(_) => BrokerControlError::UnexpectedResponse, | ||
| _ => BrokerControlError::Transport, | ||
| } | ||
| } | ||
|
|
||
| pub(crate) fn control_from_local<Platform, T>(local: BrokerLocal<T>) -> Arc<dyn BrokerControl> | ||
| where | ||
| Platform: RawSyncPrimitivesProvider, | ||
| T: LocalControlChannel + Send + 'static, | ||
| { | ||
| Arc::new(BrokerLocalControl::<Platform, T>::new(local)) | ||
| } | ||
|
|
||
| pub(crate) struct BrokerState<Platform: RawSyncPrimitivesProvider> { | ||
| control: Option<Arc<dyn BrokerControl>>, | ||
| _marker: core::marker::PhantomData<Platform>, | ||
| } | ||
|
|
||
| impl<Platform: RawSyncPrimitivesProvider> BrokerState<Platform> { | ||
| pub(crate) fn new(control: Option<Arc<dyn BrokerControl>>) -> Self { | ||
| Self { | ||
| control, | ||
| _marker: core::marker::PhantomData, | ||
| } | ||
| } | ||
|
|
||
| pub(crate) fn control(&self) -> Option<Arc<dyn BrokerControl>> { | ||
| self.control.clone() | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.