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

first pass using codegen instead of reflection #73

Merged
merged 7 commits into from
Jul 14, 2021

Conversation

raboof
Copy link
Contributor

@raboof raboof commented Jul 1, 2021

Manually create a CustomerValueEntityHandler that would be generated as part of codegen.

Added basic code to hook it into Main, but that API would still change and partly be generated.

Reading the codegen code, it's clear we're losing some features that used to be available with codegen, marked them with TODO's - we should consider whether we're OK with losing them or want to introduce new mechanisms.

@raboof raboof force-pushed the wip-52-replace-reflection branch from 9e9918a to da18abb Compare July 1, 2021 10:18
Copy link
Contributor

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

this is looking very promising

Effect<? extends GeneratedMessageV3> effect = invoke(command, adaptedContext);
// TODO we used to support accepting ScalaPB and Jackson objects as responses as well.
// Are we OK with losing that? I guess we could have separate methods for that on the
// builder, though it's not obvious how to achieve type-safety for those then.
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, I think we still want the json support. Could perhaps be an additional proto option on the entity (or even rpc) and we would generate different conversion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the json support some specific proto type that we could identify here (and turn to some json model) or how did that actually work?

(Somewhat confusing when there is also transcoding from json to proto in the proxy)

new CustomerValueEntityHandler(
// TODO I guess construction the Entity should somehow remain part of the
// customer API, so they can pass
// in anything they like in the constructor, including the context?
Copy link
Contributor

Choose a reason for hiding this comment

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

yes, we should change the registration methods to take a factory lambda CreationContext -> ValueEntity

@raboof raboof force-pushed the wip-52-replace-reflection branch 2 times, most recently from cd0f01a to 3f61f0d Compare July 1, 2021 13:53
Base automatically changed from wip-50-effect-patriknw to sdk-codegen-dev July 1, 2021 16:00
@raboof raboof force-pushed the wip-52-replace-reflection branch from 3f61f0d to a47d660 Compare July 5, 2021 14:24
raboof added a commit to raboof/akkaserverless-java-sdk that referenced this pull request Jul 5, 2021
raboof added a commit that referenced this pull request Jul 6, 2021
@raboof raboof force-pushed the wip-52-replace-reflection branch from 77adc6e to d21a262 Compare July 6, 2021 07:25
johanandren pushed a commit that referenced this pull request Jul 6, 2021
CustomerDomain.CustomerState parsedState =
CustomerDomain.CustomerState.parseFrom(state.getValue());
// TODO we used to support passing in the command as Jackson-parsed model object
// or as ScalaPB class as well. With this change we tie ourselves to Java protobuf.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can solve the ScalaPB part when we get to doing a Scala SDK?

@raboof raboof force-pushed the wip-52-replace-reflection branch from 65efcfb to 37de787 Compare July 6, 2021 15:34
@@ -25,7 +25,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class ShoppingCartImpl extends AbstractShoppingCart {
public class ShoppingCartImpl extends ShoppingCartInterface2 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ups, my bad!

@raboof raboof force-pushed the wip-52-replace-reflection branch from 35ae858 to 0764005 Compare July 8, 2021 12:49
@raboof raboof mentioned this pull request Jul 9, 2021
20 tasks
Comment on lines +26 to +28
option (akkaserverless.service) = {
type : SERVICE_TYPE_VIEW
};
Copy link
Member

Choose a reason for hiding this comment

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

We don't need this for now. This is only needed when using the codegen and the eventing sample doesn't use it. Anyway, I will remove it for now since I will be pushing to this PR (soon).

Manually create a `CustomerValueEntityHandler` that would be generated
as part of codegen.

Added basic code to hook it into `Main`, but that API would still change
and partly be generated.

Reading the codegen code, it's clear we're losing some features that
used to be available with codegen, marked them with TODO's - we should
consider whether we're OK with losing them or want to introduce new
mechanisms.
Regenerate test data against framework 0.7.0-beta.9
and the 'current' sdk.

Had to adapt the test to reflect the changes in package
in 32d1c07 and add a service type option to the view
proto that I couldn't find anywhere in the history.
@raboof raboof force-pushed the wip-52-replace-reflection branch from 0764005 to e236356 Compare July 13, 2021 12:59
@octonato octonato changed the title [WIP] first pass using codegen instead of reflection first pass using codegen instead of reflection Jul 14, 2021
@octonato octonato marked this pull request as ready for review July 14, 2021 10:59
Copy link
Member

@octonato octonato left a comment

Choose a reason for hiding this comment

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

I think we should merge this one for now.

I have done some experiments for the handler, but better to add on a follow up PR.

@octonato octonato merged commit 681cb9f into sdk-codegen-dev Jul 14, 2021
@octonato octonato deleted the wip-52-replace-reflection branch July 14, 2021 14: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.

None yet

4 participants