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

Add rpc and local attribute #17

Merged
merged 3 commits into from
Jan 5, 2024
Merged

Add rpc and local attribute #17

merged 3 commits into from
Jan 5, 2024

Conversation

zklgame
Copy link
Collaborator

@zklgame zklgame commented Jan 4, 2024

This MR did:

  • add local attribute
  • add persistence in RPC

Copy link

codecov bot commented Jan 4, 2024

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (409c5c2) 76.64% compared to head (1d7cb3d) 77.34%.

❗ Current head 1d7cb3d differs from pull request most recent head 72b3d64. Consider uploading reports for the commit 72b3d64 to get more accurate results

Files Patch % Lines
.../main/java/io/xcherry/core/rpc/RpcInterceptor.java 62.50% 3 Missing and 3 partials ⚠️
...rsistence/read_request/AppDatabaseReadRequest.java 61.53% 3 Missing and 2 partials ⚠️
...e/schema/local_attribute/LocalAttributeSchema.java 79.16% 3 Missing and 2 partials ⚠️
...rry/core/persistence/schema/PersistenceSchema.java 73.33% 2 Missing and 2 partials ⚠️
...va/io/xcherry/core/process/ProcessStartConfig.java 71.42% 2 Missing and 2 partials ⚠️
.../java/io/xcherry/core/state/AsyncStateOptions.java 57.14% 1 Missing and 2 partials ⚠️
...istence/LocalAttributeSchemaNotMatchException.java 0.00% 2 Missing ⚠️
.../java/io/xcherry/core/persistence/Persistence.java 94.73% 1 Missing and 1 partial ⚠️
...c/main/java/io/xcherry/core/utils/ProcessUtil.java 80.00% 0 Missing and 2 partials ⚠️
...ocal_attribute/LocalAttributeKeyValueSelector.java 80.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main      #17      +/-   ##
============================================
+ Coverage     76.64%   77.34%   +0.69%     
- Complexity      308      374      +66     
============================================
  Files            55       63       +8     
  Lines           959     1121     +162     
  Branches         58       74      +16     
============================================
+ Hits            735      867     +132     
- Misses          172      188      +16     
- Partials         52       66      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -0,0 +1,8 @@
package io.xcherry.core.exception.persistence;

public class LocalAttributeNotFoundException extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this exception? I don't remember a use case

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's thrown when the attribute doesn't have a value, then I would prefer returning null. Because it's very common to start with empty/null and handling this exception is sometimes cumbersome

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sounds good. For local attributes, null should be enough. While for app database, we throw not found exception if a table or column does not exist.

@@ -0,0 +1,8 @@
package io.xcherry.core.exception.persistence;

public class LocalAttributeSchemaNotMatchException extends RuntimeException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe LocalAttributeSchemaException extends ProcessDefinitionException

* @param key key of the local attribute.
* @param value value of the local attribute.
*/
public void upsertLocalAttribute(final String key, final Object value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

probably just setLocalAttribute to pair with getLocalAttribute. You can keep the comment to make it more clear

@@ -0,0 +1,66 @@
package io.xcherry.core.persistence.read_request;
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it's probably not a good practice to use underscore for package name in Java. I never see that in any popular libraries

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, making all lower case without _ is also recommended:
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html


@Getter
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class LocalAttributeKeySchema {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like LocalAttributeDef is shorter and clear enough just like in iwf Java SDK

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is to be consistent with existing app database names. We are using xxxSchema.

*
* @return the name as defined in a {@link RpcPersistenceReadRequest}.
*/
String rpcPersistenceReadRequestName() default "";
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a note that we need another PR to clean up things a little big to get rid of App database later and move back to a simpler model like iwf..

@zklgame zklgame merged commit f5348f2 into main Jan 5, 2024
1 check passed
@zklgame zklgame deleted the add_rpc_and_local_attribute branch January 5, 2024 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants