Skip to content

Conversation

zhihuizhang17
Copy link
Contributor

Add an accumulator (GrpcReflection.Service.Builder.Acc) so the builder gathers all symbols and aliases before emitting a single FileDescriptorProto per actual proto file.

@zhihuizhang17
Copy link
Contributor Author

#61

Copy link
Collaborator

@mjheilmann mjheilmann left a comment

Choose a reason for hiding this comment

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

This looks like a pretty significant amount of changes, I'm not sure I follow all of them and their need

defmodule GrpcReflection.Service.Builder.Acc do
@moduledoc false

defstruct services: [],
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like State, except it externalizes the update/merge operations

end

cond do
String.contains?(base, "/priv/protos/") ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

/priv/protos/ and /test/support/protos are magic strings that might only apply to this project and the examples directories.

It is not appropriate to risk leaking users file directory structure if they don't align with one of these. This might need some configuration to identify source proto paths to properly and safely trim from dynamic locations

"testserviceV2.TestService.proto",
"testserviceV2.TestService.proto"
]
assert Enum.sort(Enum.uniq(names)) ==
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is Enu.uniq covering for something?

alias GrpcReflection.Service.State

@spec build_reflection_tree(any()) ::
{:error, <<_::216>>} | {:ok, GrpcReflection.Service.State.t()}
Copy link
Collaborator

Choose a reason for hiding this comment

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

{:error, <<_::216>>} is an odd and specific typespec, where is this coming from?

def trim_symbol("." <> symbol), do: symbol
def trim_symbol(symbol), do: symbol

def proto_filename(module) do
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is reliable when there are protobuf options like https://github.com/elixir-protobuf/protobuf?tab=readme-ov-file#one-file-per-module that can be triggered by users. We would need to restrict them from using that option or find an alternative

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You really raised a good point. I will do more investigation about this.

Comment on lines +164 to +165
module.__info__(:compile)
|> Keyword.get(:source)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this information normally available in a production build?

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.

2 participants