Skip to content

Support ActorMethod to change method's name.#448

Merged
artursouza merged 4 commits intodapr:masterfrom
artursouza:actor_method_name
Jan 20, 2021
Merged

Support ActorMethod to change method's name.#448
artursouza merged 4 commits intodapr:masterfrom
artursouza:actor_method_name

Conversation

@artursouza
Copy link
Copy Markdown
Contributor

@artursouza artursouza commented Jan 19, 2021

Description

Support ActorMethod to change method's name.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #444

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

* @return Actor's method return type.
*/
Class returns();
Class returns() default Void.class;
Copy link
Copy Markdown
Contributor Author

@artursouza artursouza Jan 19, 2021

Choose a reason for hiding this comment

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

To make this optional, a default value must be provided. On the other hand, null is not allowed in Java for annotation attributes. The best I found was to use Void.class here. The idea is that this is only needed when the result object is Mono, so T can be hinted to the Actor runtime - this is a limitation of the Java programming language that we need to overcome. Providing this default will make this optional when users just want to set name.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The only other option I could think of would be to declare your own sentinel value.

I'm fine either way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am leaning towards using a sentinel class, called Default for that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Created an "internal" class called "Undefined". It reads better now. Please, take a look.

Comment thread examples/src/main/java/io/dapr/examples/actors/README.md Outdated
Comment thread sdk-actors/src/main/java/io/dapr/actors/client/ActorProxyImpl.java
*/
class ActorProxyImpl implements ActorProxy, InvocationHandler {

private static final String UNDEFINED_CLASS_NAME = "io.dapr.actors.Undefined";
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We cannot refer to the class since it is internal to the package in which it was declared.

Comment thread examples/src/main/java/io/dapr/examples/actors/README.md Outdated
Co-authored-by: Ryan Nowak <nowakra@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 20, 2021

Codecov Report

Merging #448 (3da6e61) into master (d43272f) will decrease coverage by 0.19%.
The diff coverage is 88.23%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #448      +/-   ##
============================================
- Coverage     83.32%   83.12%   -0.20%     
- Complexity      858      861       +3     
============================================
  Files            74       74              
  Lines          2548     2554       +6     
  Branches        259      261       +2     
============================================
  Hits           2123     2123              
- Misses          299      302       +3     
- Partials        126      129       +3     
Impacted Files Coverage Δ Complexity Δ
...ava/io/dapr/actors/runtime/ActorMethodInfoMap.java 94.11% <80.00%> (-5.89%) 7.00 <0.00> (+1.00) ⬇️
...ain/java/io/dapr/actors/client/ActorProxyImpl.java 88.37% <91.66%> (-1.88%) 27.00 <0.00> (+3.00) ⬇️
sdk/src/main/java/io/dapr/utils/Retry.java 50.00% <0.00%> (-25.00%) 1.00% <0.00%> (-1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d43272f...651c778. Read the comment docs.

@artursouza artursouza merged commit 446cd17 into dapr:master Jan 20, 2021
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.

@ActorMethod to override method's name for client and service

2 participants