Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Add TCK model test for Actions #468

Merged
merged 1 commit into from
Nov 4, 2020
Merged

Conversation

pvlugter
Copy link
Member

More on evolving the TCK: #316. Add simple TCK model tests for Actions.

Currently only implemented for java-support, which is set up for TCK model tests. This did uncover a couple of things in the java-support implementation: side effects were not being returned to the proxy, and there was no support for failure replies.

@marcellanz
Copy link
Contributor

marcellanz commented Oct 21, 2020

This did uncover a couple of things

nice! Best applied usage of a TCK :)
Looking forward to use it for Go support.

import java.util.concurrent.CompletionStage;

@Action
public class ActionTckModelBehavior {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this Entity different to the eventsourced TCK entities as it is named Behaviour(I think this is an Akka/Actor thing? I don't know Akka) as the eventsourced Entity is not named with this pattern EventSourcedTckModelEntity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actions are not considered to be Entities, in the definitions we've been using. Where an Entity is primarily defined by having a distinct identity, associated with its id or key. I think the usual pattern will be to name actions with Action, and I originally had ActionTckModelAction and ActionTwoAction here, and then tried naming it with Behaviour instead to avoid the awkwardness. Happy to find a naming convention and use it here in the TCK too.

private ServiceCall serviceTwoRequest(Context context, String id) {
return context
.serviceCallFactory()
.lookup("cloudstate.tck.model.action.ActionTwo", "Call", OtherRequest.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

No issue here, but I'm surprised to see the Java gRPC service descriptors same as, the ones of the Go prototbuf plugin, do not export typesafe identifiers for services and service names.

Copy link
Contributor

Choose a reason for hiding this comment

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

… there is work underway to change that for the go gRPC plugin grpc/grpc-go#3762

Copy link
Member Author

Choose a reason for hiding this comment

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

The Scala service descriptors do have the identifiers. Maybe they've been added for Java as well now. Good that there will be a better API for Go.

Copy link
Member Author

Choose a reason for hiding this comment

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

Akka gRPC for Java does of course generate a bunch of things, including static service names that can be used here. The method descriptors in the client all look to be private, otherwise they could be used for a lookup here. Agree that it would be good to have typesafe APIs for Cloudstate service calls, and we should otherwise look at generating these. The Java support is very reflection and runtime-based currently.

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've updated this to use the generated service name at least, from Akka gRPC (the generation was actually disabled, as only the java protoc generation is needed).


public ActionTckModelBehavior() {}

@CallHandler

Choose a reason for hiding this comment

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

Just a non-PR comment. Why did we choose CallHandler instead of CommandHandler? I don't understand why we need to change the semantics since the behavior is implicit in the type of Entity used, we shouldn't have to call it CallHandler just because it is a stateless entity. This is definitely the case with "pattern is having no pattern".

Copy link
Member Author

@pvlugter pvlugter Oct 26, 2020

Choose a reason for hiding this comment

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

For Actions or Functions (which are not Entities) I expect EventHandler may be the most commonly used in other similar solutions, but I think that was seen as confusing with event-sourced entities having a more specific use of event handling. In some discussions, just using Handler for actions was discussed. I'll let @jroper comment on why it's CallHandler currently. Sticking to CommandHandler for both entities and actions seems okay to me too.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sleipnir, do you want to create an issue for the CallHandler naming? So we track discussion there and remember to make changes.

@pvlugter
Copy link
Member Author

pvlugter commented Nov 4, 2020

As it's been a couple of weeks, I'll merge this now, and make it simpler for the next TCK extensions. Post-merge reviews still welcome of course.

@pvlugter pvlugter merged commit 92a4f48 into cloudstateio:master Nov 4, 2020
@pvlugter pvlugter deleted the action-tck branch November 4, 2020 22:55
@pvlugter pvlugter mentioned this pull request Nov 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants