-
Notifications
You must be signed in to change notification settings - Fork 220
[actor] Add Unreliable Feedback Type #3849
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
13 commits
Select commit
Hold shift + click to select a range
fa1df84
spike
patrick-ogrady 2e16f57
more polish
patrick-ogrady 99c1891
use unreliable
patrick-ogrady 32f2dbe
nits
patrick-ogrady 293c7cf
outcome
patrick-ogrady 2cd6da0
cleanup
patrick-ogrady c984571
nits
patrick-ogrady e1fbdfb
nit
patrick-ogrady 4ca6ab9
dedup code
patrick-ogrady 3eb4fd9
loom
patrick-ogrady 45090b7
make more ergonomic
patrick-ogrady 5b003b8
nit
patrick-ogrady cf05798
lints
patrick-ogrady 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
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
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 |
|---|---|---|
|
|
@@ -17,8 +17,6 @@ commonware_macros::stability_scope!(BETA { | |
| Ok, | ||
| /// The submission exceeded configured capacity but was handled by the overflow policy. | ||
| Backoff, | ||
| /// The submission exceeded configured capacity and was rejected by the overflow policy. | ||
| Rejected, | ||
| /// The endpoint is closed. | ||
| Closed, | ||
| } | ||
|
|
@@ -30,5 +28,49 @@ commonware_macros::stability_scope!(BETA { | |
| } | ||
| } | ||
|
|
||
| /// Feedback from endpoints that may reject work under backpressure. | ||
| #[derive(Clone, Copy, Debug, PartialEq, Eq)] | ||
| pub enum Unreliable<T> { | ||
|
Contributor
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. This is kept generic in case we start adding more "outcomes" ... if we eventually go a different route, we can do |
||
| /// Endpoint outcome from the submission attempt. | ||
| Outcome(T), | ||
| /// The work was rejected by the endpoint. | ||
| Rejected, | ||
| } | ||
|
|
||
| impl<T> Unreliable<T> { | ||
| /// Wrap an outcome for an operation that may reject work. | ||
| pub const fn new(outcome: T) -> Self { | ||
| Self::Outcome(outcome) | ||
| } | ||
|
|
||
| /// Create a rejected result. | ||
| pub const fn rejected() -> Self { | ||
| Self::Rejected | ||
| } | ||
|
|
||
| /// Returns `true` when the operation was rejected before producing an outcome. | ||
| pub const fn is_rejected(&self) -> bool { | ||
| matches!(self, Self::Rejected) | ||
| } | ||
|
|
||
| /// Returns the outcome when the operation was not rejected. | ||
| pub fn outcome(self) -> Option<T> { | ||
| match self { | ||
| Self::Outcome(outcome) => Some(outcome), | ||
| Self::Rejected => None, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Unreliable<Feedback> { | ||
| /// Returns `true` when the endpoint handled the submission. | ||
| pub const fn accepted(self) -> bool { | ||
| match self { | ||
| Self::Outcome(feedback) => feedback.accepted(), | ||
| Self::Rejected => false, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub mod mailbox; | ||
| }); | ||
Oops, something went wrong.
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.