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

More idiomatic play integration #420 #534

Merged
merged 3 commits into from
Mar 21, 2019

Conversation

ctoomey
Copy link
Contributor

@ctoomey ctoomey commented Feb 28, 2019

Continuation of PR #447, using a new branch with single composite commit.

@akka-ci
Copy link

akka-ci commented Feb 28, 2019

Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK TO TEST' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged.

For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask!

@johanandren
Copy link
Member

Refs #420

@raboof
Copy link
Member

raboof commented Feb 28, 2019

OK TO TEST

public Function1<RequestHeader, EssentialAction> createHandler(String serviceName, Materializer mat) {
return new Function1<RequestHeader, EssentialAction>() {
public EssentialAction apply(RequestHeader reqOuter) {
Function<HttpRequest, CompletionStage<HttpResponse>> handler = @{serviceName}HandlerFactory.create(Abstract@{serviceName}Router.this, serviceName, mat, eHandler, system);
Copy link
Member

Choose a reason for hiding this comment

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

If I'm reading this correctly, this would now be called for every request. It looks like that would not be necessary, and it could be created once outside of the function. Would that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this is only called once during initialization. See here.

It shouldn't be public though, will change that.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, createHandler is only called once, but line 66 is inside the function that is returned by createHandler, and that is called for every request - unless I'm misreading this somehow, it could be moved to between line 64 to only create the handler once? (haven't tried though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right, I was looking at line 64. Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


def createStreamingAction(handler: HttpRequest => Future[HttpResponse])(implicit ec: ExecutionContext): EssentialAction =
actionBuilder.async(streamBodyParser) { req =>
handler(playToAkkaRequestStream(req)).map(akkaToPlayResp)
Copy link
Member

Choose a reason for hiding this comment

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

As discussed in #420 (comment), this 'additional roundtrip' is of course more or less unavoidable if you want to take into account the changes to the Play request, but does come at some performance cost.

How much performance cost, and whether that cost is acceptable, of course highly depends on the application and should be measured/considered by the user.

I think we should add some documentation to this option, and explain clearly that the trade-off here: this option allows you to use your existing Play action composition approach, at the expense of some performance (which is why it is not the default). Later, eventually, we could also document alternate ways to achieve cross-cutting concerns there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently there's no mention of the Play integration in the docs. Where do you suggest documenting this?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, the Play gRPC documentation has already moved to https://github.com/playframework/play-grpc - I guess we will have to move the documentation for this feature to a separate PR over there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll work on that before long, but you can go ahead and merge this right?

@raboof raboof requested a review from marcospereira March 4, 2019 13:25
@ctoomey
Copy link
Contributor Author

ctoomey commented Mar 11, 2019

Hi @marcospereira , when do you think you can review this? Want to get closure on this odyssey.

@ctoomey
Copy link
Contributor Author

ctoomey commented Mar 18, 2019

Hi @raboof , nothing's happening from your added reviewer and I'd like this to get merged and done with. Please advise.

@raboof
Copy link
Member

raboof commented Mar 21, 2019

This is now good to go - thanks for another great contribution! 🎉

@raboof raboof merged commit 114b2f3 into akka:master Mar 21, 2019
@raboof raboof added this to the 0.7.0 milestone Mar 21, 2019
@ctoomey
Copy link
Contributor Author

ctoomey commented Mar 21, 2019

Yay! Thanks @raboof .

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.

4 participants