-
Notifications
You must be signed in to change notification settings - Fork 87
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
Create new method with the FieldMask WKT #9
Comments
I tried playing around with this and I've come to several conclusions for now:
|
Tagging @timonwong to see if he has anything to add to this discussion. |
Nice. Yes lets first see how it should work with golang/protobuf and then try to get it working with gogo/protobuf. Thanks so much for pushing this forward :) |
I was doing some more testing of field masks in the grpc-gateway, and surprisingly it works with protoc-gen-go, so there's potentially something here that protoc-gen-gogo can do differently, but I'm not entirely sure what yet. I created https://github.com/johanbrandhorst/field-mask-test as an example of using the gRPC gateway with a field mask, and it works (???). I will try and reproduce the same thing in the gogo/grpc-example repo and see where it breaks next. |
I'm also continuing the discussion in grpc-ecosystem/grpc-gateway#529 (comment) |
Interesting development; if gogo/protobuf WKT implemented |
IF it really helps to solve the problem then:
|
It would only solve it in the |
Ok so they are only using proto.MessageName and this fixes the compatibility issue? |
I did a quick search for proto.MessageType and couldn't find any uses, so yeah, perhaps? It doesn't solve the problem of the jsonpb marshaler using golang/protobuf but that's completely configurable by the user at least. |
I think we should consider restricting it to the WKT though, since the |
Ok what about we make a pull request on gogoprotobuf types folder and add XXX_MessageName methods to all the wkts and see if fieldmask starts working? |
If it solves a problem, we merge it :) |
@awalterschulze lets do it |
cool :) |
Uh, I suppose I could try it out first, sure, let me get back to you. |
Thank you so much. I really appreciate it. |
@johanbrandhorst
|
@timonwong I can investigate that at the same time, that would be huge. |
Oh wow // MarshalAny takes the protocol buffer and encodes it into google.protobuf.Any.
func MarshalAny(pb proto.Message) (*Any, error) {
value, err := proto.Marshal(pb)
if err != nil {
return nil, err
}
return &Any{TypeUrl: googleApis + proto.MessageName(pb), Value: value}, nil
} Seems like that should work :) So then generating XXX_MessageName for all messages should solve MarshalAny. |
Looking at the code it looks like even UnmarshalAny should work. |
Another caveat about jsonpb codec in grpc-gateway to handle
|
The issue is handled by supplying a custom JSON marshaller, we'll never be able to work around the problem of |
The latest merge to this repo shows how to use the |
I've made some progress on this. In addition to adding |
Replacing the cockroachdb Marshaler with https://github.com/abursavich/gogomarshal (from gogo/protobuf#166) works out of the box (when It does output these worrying warnings though:
Now I'm sure I've seen this before, but I can't remember where or why. @awalterschulze any ideas about what causes this? |
They don't happen with the cockroachdb Marshaler 🤔 |
I've just pushed up #11 which is a working example of using google.protobuf.FieldMask. I've switch marshaler and manually implemented Outstanding fixes:
|
On the warnings the solution seems to be in this issue And here is an original issue report The solution seems to have something to do with
But, since I am not gRPC user :( I never confirmed it. |
@johanbrandhorst on XXX_MessageName I just want to confirm, this won't only be needed for FieldMask, but potentially for all user defined protobuf messages.
What do you think? |
Yeah I'm not sure which yet, this could potentially be an alternative to goproto_registration. Implement it as an option to start with I think. I guess there's no harm in users turning it on for their messages or files. |
Doesn't seem like either of those issue figured out why the messages appeared, so I'll do some more digging. Setting |
Oh that is very interesting. Hmmm. |
In the mean time. What exactly would the MessageName of fieldmask, just as an example. |
In other words, will this work? func (*FieldMask) XXX_MessageName() string {
return "google.protobuf.FieldMask"
} |
Yes, that works. It has to be the same as the name that is being registered. |
It seems as though cockroachdb is calling jsonpb.Unmarshal While gogomarshal is calling encoding/json Unmarshal That is probably a bug. |
But I don't know how that is resulting in GetProperties being called. |
I know that it is |
the option to generate XXX_MessageName has now been pushed to master and I have also generated it for all the well known types, including fieldmask. |
Wow, that was fast! |
Just like you :) |
With the FieldMask now officially implementing The next question is if the |
Done googleapis now has XXX_MessageName generated for each type. |
Great and fast job guys! 👏 |
Need to find how to work around https://github.com/grpc-ecosystem/grpc-gateway/blob/58f78b988bc393694cef62b92c5cde77e4742ff5/runtime/query.go#L275 in gRPC-Gateway.
The text was updated successfully, but these errors were encountered: