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

Services and Discovery are not generic #1

Open
lukos opened this issue Apr 27, 2021 · 1 comment
Open

Services and Discovery are not generic #1

lukos opened this issue Apr 27, 2021 · 1 comment

Comments

@lukos
Copy link

lukos commented Apr 27, 2021

Firstly, thanks for this library, it has saved me a lot of time building Envoy's protos. I have an issue though related to the lack of generic support. It seems like the original protos are not correct in Envoy so I am stuck on how to achieve something like the following.

var response = new DiscoveryResponse();
var cluster = new Cluster();

response.Resources.Add(cluster);    // Error, Cannot convert from Cluster to WellKnownTypes.Any

I understand the error, since Resources is defined as RepeatedField whereas Cluster does not inherit from anything. This seems strange since I would expect either that Cluster inherits Any so it can be used in the "Object/Any" repeated field or otherwise, I'm not sure if protobuf supports generics so that DiscoveryResponse in the method e.g. ClusterDiscoveryServiceBase is generic like:

Task<DiscoveryResponse<Cluster>> FetchClusters(DiscoveryRequest request, ServerCallContext context);

So that the repeated field resources is of T rather than Any. Do you know what I am doing wrong here?

@lukos
Copy link
Author

lukos commented Apr 27, 2021

I have found Any.Pack(IMessage) but not sure if that is the correct way to do it. It will be a while before I can test my service.

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

No branches or pull requests

1 participant