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

Added metadata support to the proxy#366

Merged
jroper merged 8 commits intocloudstateio:masterfrom
jroper:metadata-support
Jul 1, 2020
Merged

Added metadata support to the proxy#366
jroper merged 8 commits intocloudstateio:masterfrom
jroper:metadata-support

Conversation

@jroper
Copy link
Copy Markdown
Member

@jroper jroper commented Jun 24, 2020

This adds metadata support to the proxy, and also modifies the contract in the protocol for stateless functions.

This PR has been pulled out of the projections PR, in an effort to try and simplify that PR. Eventing support has been completely disabled in this PR (large parts of code are commented out), when the projections PR is merged, that will include all the necessary changes to eventing to make it work with the changes to everything else in this PR.

What has been done:

  • Metadata support added to protocols and proxy
  • No user function support libraries have been modified. The metadata has been added to the protocol in a backwards compatible way, so they shouldn't need to be updated.
  • The one exception to this is streaming support for stateless functions in JavaScript, but that needs rewriting anyway, and I have those changes ready for a future PR, so I'm not too concerned about that.

}

repeated SideEffect side_effects = 4;
repeated SideEffect side_effects = 5;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why 5?

Comment thread proxy/core/src/main/scala/io/cloudstate/proxy/Serve.scala Outdated
@viktorklang
Copy link
Copy Markdown
Contributor

@jroper Tests?


// Handle a streamed in command.
//
// The first message in will contain the request metadata, including the service name and command
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@jroper , I have been talking about this PR with @marcellanz and we have an important question, why do you say that metadata will be sent in the first message if the metadata is defined in the protocol and is contained within the message to be forwarded? I think the metadata in that case should be passed on message by message if the underlying protocols so support. Did you mean that metadata will not be forwarded by each message? That is, will subsequent messages not contain associated metadata?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll clarify.

I think it should be this:

  • If the underlying transport only supports per call metadata, that metadata will be on the first message, and not on the others.
  • If the underlying transport supports per message metadata, each message will contain that metadata.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks @jroper
We imagined it, thank you for clarifying that. It would be nice to add this text to the PR

@jroper
Copy link
Copy Markdown
Member Author

jroper commented Jun 25, 2020

Re: tests - without a client side implementation, it's a bit hard to test meaningfully. That will come in subsequent PRs.

Copy link
Copy Markdown
Member

@pvlugter pvlugter left a comment

Choose a reason for hiding this comment

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

Not knowing the serve code or its history, this all looks fine to me.

For big changes like this (including the other related PRs), I'd be fine if it was all in one PR but broken down into commits that can be reviewed separately, with all the changes tested together.

Comment thread protocols/protocol/cloudstate/entity.proto Outdated
Comment thread protocols/protocol/cloudstate/entity.proto Outdated
Comment thread protocols/protocol/cloudstate/entity.proto Outdated
Comment thread protocols/protocol/cloudstate/entity.proto Outdated
Comment thread protocols/protocol/cloudstate/function.proto Outdated
final def serve(
services: List[
(ServiceDescriptor, PartialFunction[HttpRequest, Future[(List[HttpHeader], Source[ProtobufAny, NotUsed])]])
]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Funny that the type is long enough to be formatted like this. If the request handler type is used in a few places, maybe this would be better with some type aliases?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I think actually what would be better is a big refactor of this, not just with type aliases, but traits, so that things can be documented nicely.

reply @ UserFunctionReply(Some(ClientAction(ClientAction.Action.Reply(Reply(_, metadata, _)), _)),
_,
_)
) =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Funky match, just to get to the metadata :)

Copy link
Copy Markdown
Member

@pvlugter pvlugter left a comment

Choose a reason for hiding this comment

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

I'm fine with changes being broken apart over multiple PRs in this case, and trust that a lot of it's been tested manually, but ideally we could have changes with tests together, in a series of commits in one PR.

I restarted the native-image test, which has been failing. We've been going over our CircleCI subscription, so we may want to disable those for PRs, and ideally have a label or something that can be added to test this.

And there's a merge conflict with master.

jroper and others added 6 commits July 1, 2020 14:31
This adds metadata support to the proxy, and also modifies the contract
in the protocol for stateless functions.

This PR has been pulled out of the projections PR, in an effort to try and
simplify that PR. Eventing support has been completely disabled in this
PR (large parts of code are commented out), when the projections PR is
merged, that will include all the necessary changes to eventing to make
it work with the changes to everything else in this PR.

What has been done:

* Metadata support added to protocols and proxy
* No user function support libraries have been modified. The metadata
  has been added to the protocol in a backwards compatible way, so they
  shouldn't need to be updated.
* The one exception to this is streaming support for stateless functions
  in JavaScript, but that needs rewriting anyway, and I have those
  changes ready for a future PR, so I'm not too concerned about that.
Co-authored-by: Viktor Klang (√) <viktor.klang@gmail.com>
Co-authored-by: Peter Vlugter <pvlugter@users.noreply.github.com>
Co-authored-by: Peter Vlugter <pvlugter@users.noreply.github.com>
Co-authored-by: Peter Vlugter <pvlugter@users.noreply.github.com>
@jroper jroper force-pushed the metadata-support branch from afe28e8 to b997ba9 Compare July 1, 2020 05:23
jroper and others added 2 commits July 1, 2020 15:28
Co-authored-by: Peter Vlugter <pvlugter@users.noreply.github.com>
Co-authored-by: Peter Vlugter <pvlugter@users.noreply.github.com>
@jroper jroper merged commit 1c61d6e into cloudstateio:master Jul 1, 2020
@jroper jroper deleted the metadata-support branch July 1, 2020 06:00
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.

4 participants