-
Notifications
You must be signed in to change notification settings - Fork 1
chore: conditionally process data address on resume flow #64
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
Closed
ronjaquensel
wants to merge
1
commit into
eclipse-dataplane-core:main
from
FraunhoferISST:chore/data-address-handling-for-resume
+11
−4
Closed
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,8 @@ | |
| import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; | ||
| import static jakarta.ws.rs.core.HttpHeaders.AUTHORIZATION; | ||
| import static java.util.Collections.emptyMap; | ||
| import static org.eclipse.dataplane.domain.dataflow.DataFlow.Type.CONSUMER; | ||
| import static org.eclipse.dataplane.domain.dataflow.DataFlow.Type.PROVIDER; | ||
|
|
||
| public class Dataplane { | ||
|
|
||
|
|
@@ -132,7 +134,7 @@ public Result<DataFlowStatusMessage> prepare(String controlplaneId, DataFlowPrep | |
| .counterPartyId(message.counterPartyId()) | ||
| .dataspaceContext(message.dataspaceContext()) | ||
| .controlplaneId(controlplaneId) | ||
| .type(DataFlow.Type.CONSUMER) | ||
| .type(CONSUMER) | ||
| .build(); | ||
|
|
||
| return checkControlPlane(controlplaneId) | ||
|
|
@@ -167,7 +169,7 @@ public Result<DataFlowStatusMessage> start(String controlplaneId, DataFlowStartM | |
| .counterPartyId(message.counterPartyId()) | ||
| .dataspaceContext(message.dataspaceContext()) | ||
| .controlplaneId(controlplaneId) | ||
| .type(DataFlow.Type.PROVIDER) | ||
| .type(PROVIDER) | ||
| .build(); | ||
|
|
||
| return checkControlPlane(controlplaneId) | ||
|
|
@@ -201,7 +203,9 @@ public Result<Void> suspend(String flowId, DataFlowSuspendMessage message) { | |
| public Result<DataFlowStatusMessage> resume(String flowId, DataFlowResumeMessage message) { | ||
| return dataFlowStore.findById(flowId) | ||
| .map(dataFlow -> { | ||
| if (message.dataAddress() != null) { | ||
| var shouldReceiveDataAddress = (PROVIDER.equals(dataFlow.getType()) && dataFlow.isPush()) || | ||
| (CONSUMER.equals(dataFlow.getType()) && dataFlow.isPull()); | ||
| if (shouldReceiveDataAddress) { | ||
| dataFlow.setDataAddress(message.dataAddress()); | ||
| } | ||
| return dataFlow; | ||
|
|
@@ -210,7 +214,10 @@ public Result<DataFlowStatusMessage> resume(String flowId, DataFlowResumeMessage | |
| .compose(dataFlow -> { | ||
| dataFlow.transitionToStarted(); | ||
|
|
||
| var response = new DataFlowStatusMessage(id, flowId, dataFlow.getState().name(), dataFlow.getDataAddress(), null); | ||
| var shouldProvideDataAddress = (PROVIDER.equals(dataFlow.getType()) && dataFlow.isPull()) || | ||
| (CONSUMER.equals(dataFlow.getType()) && dataFlow.isPush()); | ||
| var dataAddress = shouldProvideDataAddress ? dataFlow.getDataAddress() : null; | ||
| var response = new DataFlowStatusMessage(id, flowId, dataFlow.getState().name(), dataAddress, null); | ||
|
Comment on lines
+217
to
+220
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. same, I think this is excessively defensive, unless there's a specific case for which the data address shouldn't be sent back, eventually let's try to describe it through a test |
||
|
|
||
| return save(dataFlow).map(it -> response); | ||
| }); | ||
|
|
||
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.
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'm not sure about this check, wouldn't the non null one already covering these cases? If the data plane receives a data address, it updates it, otherwise it uses the original one, unless there's a specific use case that we should avoid (eventually demonstrated by a test) I'd just leave the loose non-null check