Skip to content
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

feat: add pending state to ContractNegotiation and TransferProcess #3321

Merged
merged 2 commits into from
Jul 27, 2023

Conversation

ndr-brt
Copy link
Member

@ndr-brt ndr-brt commented Jul 21, 2023

What this PR changes/adds

Adds a pending field to the StateEntity extension classes (ContractNegotiation and TransferProcess), and the possibility to enable it based on ax extensible PendingGuard. (see state_machine.md docs for details)

Why it does that

This is the first step to enable "external interactions", that is the foundation for features such as the "counter offer" flow.

Further notes

  • introduced a Builder based ProcessorImpl that will supersed StateProcessorImpl
  • removed some longtime deprecated stuff related to CN and TP
  • added TransferProcessDefaultServicesExtension and ContractNegotiationDefaultServicesExtension, to tidy up a little
  • no e2e test was implemented because the feature is still not end to end complete (e.g. we're missing a way to do the state change manually)
  • extracted a SqlExecuteStatement that helps in building up INSERT and UPDATE sql statements without having to fight against String.format stuff. Ref: refactor: avoid manual SQL statements definition #3322

Linked Issue(s)

Closes #3308

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

/**
* Represent a column and its value into a JDBC prepared statement.
*
* @param columnName the name of the column.

Check notice

Code scanning / CodeQL

Spurious Javadoc @param tags

@param tag "columnName" does not match any actual type parameter of type "ColumnEntry".
* Represent a column and its value into a JDBC prepared statement.
*
* @param columnName the name of the column.
* @param value the value of the column, by default it will be '?' but it could be different.

Check notice

Code scanning / CodeQL

Spurious Javadoc @param tags

@param tag "value" does not match any actual type parameter of type "ColumnEntry".
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2023

Codecov Report

Patch coverage: 75.26% and project coverage change: +0.06 🎉

Comparison is base (e96e047) 71.91% compared to head (ae887de) 71.98%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3321      +/-   ##
==========================================
+ Coverage   71.91%   71.98%   +0.06%     
==========================================
  Files         810      810              
  Lines       16513    16613     +100     
  Branches      964      965       +1     
==========================================
+ Hits        11876    11959      +83     
- Misses       4236     4252      +16     
- Partials      401      402       +1     
Impacted Files Coverage Δ
...g/eclipse/edc/statemachine/StateProcessorImpl.java 100.00% <ø> (ø)
...t/ContractNegotiationDefaultServicesExtension.java 0.00% <0.00%> (ø)
...act/listener/ContractNegotiationEventListener.java 100.00% <ø> (ø)
.../edc/connector/transfer/TransferCoreExtension.java 0.00% <0.00%> (ø)
...nsfer/TransferProcessDefaultServicesExtension.java 0.00% <0.00%> (ø)
...ava/org/eclipse/edc/sql/statement/ColumnEntry.java 0.00% <0.00%> (ø)
...eclipse/edc/sql/statement/SqlExecuteStatement.java 0.00% <0.00%> (ø)
.../eclipse/edc/spi/persistence/StateEntityStore.java 0.00% <0.00%> (ø)
...gotiation/observe/ContractNegotiationListener.java 0.00% <ø> (ø)
...ava/org/eclipse/edc/spi/entity/StatefulEntity.java 24.52% <14.28%> (-1.56%) ⬇️
... and 15 more

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ndr-brt ndr-brt force-pushed the 3308-manual-interactions branch 4 times, most recently from 6918aad to f3065bd Compare July 24, 2023 08:21
Copy link
Member

@paullatzelsperger paullatzelsperger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation should be added here and there, LGTM otherwise.
Love the SqlExecuteStatement BTW 🚀

docs/developer/state-machine.md Outdated Show resolved Hide resolved
docs/developer/state-machine.md Outdated Show resolved Hide resolved
*/
public class StateProcessorImpl<T> implements StateProcessor {
@Deprecated(since = "0.1.3")
public class StateProcessorImpl<T> implements Processor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there really any point to deprecating this? It's an internal class, not intended for public use

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least tractus-x is using this for the EDR state machine, I think this deprecation work helps a lot migrating from version to version (because the @deprecated tag in the javadoc text)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this begs a broader discussion about SPIs, what we should and should not deprecate etc.

import static java.util.stream.Collectors.joining;
import static org.eclipse.edc.sql.statement.ColumnEntry.standardColumn;

public class SqlExecuteStatement {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc? Maybe SqlModificationStatement would be a more suitable name, to mirror the SqlQueryStatement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took the name from the methods in SqlQueryExecutor: execute (to modify) and query (to get), I think it make sense to stay consistent, I'm open to modifications but on both sides eventually

@ndr-brt ndr-brt merged commit de80081 into eclipse-edc:main Jul 27, 2023
@ndr-brt ndr-brt deleted the 3308-manual-interactions branch July 27, 2023 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core feature enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add manual interaction to state machines
4 participants