Skip to content

fix: accumulate protobuf descriptors #192

Merged
ennru merged 2 commits intolightbend:mainfrom
ennru:ennru-eventing-sample-ci
Aug 9, 2021
Merged

fix: accumulate protobuf descriptors #192
ennru merged 2 commits intolightbend:mainfrom
ennru:ennru-eventing-sample-ci

Conversation

@ennru
Copy link
Copy Markdown
Member

@ennru ennru commented Aug 4, 2021

The Eventing Shopping Cart sample doesn't work with the current codegen AFAICS.

@franciscolopezsancho franciscolopezsancho self-assigned this Aug 4, 2021
@franciscolopezsancho
Copy link
Copy Markdown
Contributor

Currently reproducing it with the very same .proto files in a test. This way we can directly test the generation itself.
This process can also be useful for later tests as an example of how to load and use the proto files from a sample in the codegen.

Comment thread .circleci/config.yml Outdated
@ennru ennru changed the title chore: try eventing shopping cart in CI fix: accumulate protobuf descriptors Aug 9, 2021
@ennru ennru requested a review from raboof August 9, 2021 12:18
Copy link
Copy Markdown
Contributor

@raboof raboof left a comment

Choose a reason for hiding this comment

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

Some questions, but if I'm reading this right it LGTM

The java-eventing-shopping-cart exercises this scenario, right?

Using[FileInputStream, Either[CannotOpen, Iterable[
Either[ReadFailure, Descriptors.FileDescriptor]
]]](
): Either[CannotOpen, Either[ReadFailure, Iterable[Descriptors.FileDescriptor]]] =
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.

So now if we fail to read one file we throw away all results? That might be OK if we're sure we need all of them anyway

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.

We bail out on any error now, before it could live with certain descriptors failing.

case Left(_) => reads
case Right(fileDescriptors) =>
try {
Right(fileDescriptors ++ List(Descriptors.FileDescriptor.buildFrom(file, fileDescriptors.toArray, true)))
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.

So we have to pass 'depended-upon' descriptors when parsing 'depending' descriptors - meaning the files must be accumulated in the 'right order'. How do we make sure they are in the right order?

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'm not sure they have to be in the right order, but maybe we should allowUnknownDependencies=false instead?

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.

I'm not sure they have to be in the right order

Whatever descriptor is the first one will be called with an empty fileDescriptors array, so if some of them need things to be available in there then that'd mean the order matters?

I'm not sure they have to be in the right order, but maybe we should allowUnknownDependencies=false instead?

I'm not sure, I guess you could have unknown dependencies (like external proto annotations that we don't care about) that we could allow?

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.

This comment is what I expected, but the API doesn't seem to allow us to first accumulate the descriptors and after that trigger linking.

I assume allowUnknownDependencies=false would make it fail when the order is wrong, but now the placeholders will be linked once the correct descriptor has been added to the list.

Copy link
Copy Markdown
Member Author

@ennru ennru left a comment

Choose a reason for hiding this comment

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

Yes, the initially failing builds show how it handled the descriptors in isolation and "invented" placeholders for unresolved references.

case Left(_) => reads
case Right(fileDescriptors) =>
try {
Right(fileDescriptors ++ List(Descriptors.FileDescriptor.buildFrom(file, fileDescriptors.toArray, true)))
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'm not sure they have to be in the right order, but maybe we should allowUnknownDependencies=false instead?

Using[FileInputStream, Either[CannotOpen, Iterable[
Either[ReadFailure, Descriptors.FileDescriptor]
]]](
): Either[CannotOpen, Either[ReadFailure, Iterable[Descriptors.FileDescriptor]]] =
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.

We bail out on any error now, before it could live with certain descriptors failing.

@ennru
Copy link
Copy Markdown
Member Author

ennru commented Aug 9, 2021

Rebased as preparation to merge as two commits.

@ennru ennru merged commit 7aaf1aa into lightbend:main Aug 9, 2021
@ennru ennru deleted the ennru-eventing-sample-ci branch August 9, 2021 15:33
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