Repository navigation
Rename IComponent result types
#797
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
b31fa4a
d3b1c12
3d86568
0cf36e0
59550a0
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 | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -175,11 +175,13 @@ void Graph::updateRunTargetInPlace(RunTarget& run_target, ComponentTaskType task | ||||||||||||||||||||||
| // RunTargets are updated in place, no need to queue them on the thread pool. | |||||||||||||||||||||||
| if (task_type == ComponentTaskType::kActivate) | |||||||||||||||||||||||
| { | |||||||||||||||||||||||
| run_target.activate(stop_source_.get_token()); | |||||||||||||||||||||||
| const IComponent::RequestResult result = run_target.activate(stop_source_.get_token()); | |||||||||||||||||||||||
| SCORE_LANGUAGE_FUTURECPP_ASSERT(result == IComponent::RequestResult::kSuccess); | |||||||||||||||||||||||
|
Contributor
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. Hmm I think it's right now safe to assert here because the run_target.activate just sets variable but not sure if we should assume that will be the case forever. I would rather log an error I think?
Member
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. Originally we just ignored the return value entirely. I think logging an error could have the same consequences (errors going unnoticed) - the log message might not be noticed if tests are passing. I would prefer keeping the assert and adding proper error handling if/when the need arises
Contributor
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 think the assert is good here because other changes might be needed if this did change, needs an assert message though to clear things up (e.g. "Run target activation cannot fail"). Also, is
Member
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.
Neither...
|
|||||||||||||||||||||||
| } | |||||||||||||||||||||||
| else | |||||||||||||||||||||||
| { | |||||||||||||||||||||||
| run_target.deactivate(stop_source_.get_token()); | |||||||||||||||||||||||
| const IComponent::RequestResult result = run_target.deactivate(stop_source_.get_token()); | |||||||||||||||||||||||
| SCORE_LANGUAGE_FUTURECPP_ASSERT(result == IComponent::RequestResult::kSuccess); | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
| current_transition_->onNodeFinished(run_target.getIdentifier()); | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
|
|
@@ -347,11 +349,11 @@ void Graph::handleComponentEvent(const ComponentEvent& event) | ||||||||||||||||||||||
| << (std::is_same_v<T, ActivationSuccessful> ? std::string_view("activation") | |||||||||||||||||||||||
| : std::string_view("deactivation")) | |||||||||||||||||||||||
| << "successfully"; | |||||||||||||||||||||||
| nodeExecuted(data.node_identifier, {}); | |||||||||||||||||||||||
| nodeExecuted(data.node_identifier, IComponent::RequestResult::kSuccess); | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
| else if constexpr (std::is_same_v<T, ActivationFailed>) | |||||||||||||||||||||||
| { | |||||||||||||||||||||||
| nodeExecuted(data.node_identifier, score::cpp::make_unexpected(data.reason)); | |||||||||||||||||||||||
| nodeExecuted(data.node_identifier, data.reason); | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
| else if constexpr (std::is_same_v<T, UnexpectedTermination>) | |||||||||||||||||||||||
| { | |||||||||||||||||||||||
|
|
@@ -368,17 +370,17 @@ void Graph::handleComponentEvent(const ComponentEvent& event) | ||||||||||||||||||||||
| } | |||||||||||||||||||||||
| else if constexpr (std::is_same_v<T, JobSkipped>) | |||||||||||||||||||||||
| { | |||||||||||||||||||||||
| nodeExecuted(data.node_identifier, {}); | |||||||||||||||||||||||
| nodeExecuted(data.node_identifier, IComponent::RequestResult::kSuccess); | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
| }, | |||||||||||||||||||||||
| event); | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| void Graph::nodeExecuted(IdentifierHash node, score::cpp::expected_blank<IComponent::ComponentError> error) | |||||||||||||||||||||||
| void Graph::nodeExecuted(IdentifierHash node, IComponent::RequestResult result) | |||||||||||||||||||||||
| { | |||||||||||||||||||||||
| bool was_last_in_queue = --jobs_in_progress_ == 0; | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
| if (!error.has_value()) | |||||||||||||||||||||||
| if (result != IComponent::RequestResult::kSuccess) | |||||||||||||||||||||||
| { | |||||||||||||||||||||||
| setState(GraphState::kAborting); | |||||||||||||||||||||||
| } | |||||||||||||||||||||||
|
|
|||||||||||||||||||||||
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.
I think
RequestResultshould still be anexpected(expected_blankI think) with an error code. Something that can bekSuccessbeing an error code seems wrong to me.