Re: [protobuf] Protobuf 3 optional vs FieldMasks

2023-01-18 Thread Jeff Sawatzky
 

After much trial and error, I've come to the conclusion that FieldMasks are 
still required if your resource has repeated or map fields. These can not 
be marked as optional and have no ability to check for presence. So in 
these cases you need a FieldMask, and in order to remain consistent in your 
update requests you may as well use FieldMasks everywhere.

FieldMasks also allow you to use your existing protocol buffer message 
types without having to mark fields as optional.


On Thursday, November 3, 2022 at 11:44:12 AM UTC-4 acoz...@google.com wrote:

> From a protobuf perspective, either approach should work, so I think it is 
> mostly a matter of preference. I think you are right that FieldMasks 
> predate proto3 optional fields and were originally designed to accommodate 
> the lack of optional fields in proto3. Now that proto3 has optional fields, 
> they are a valid alternative to FieldMask.
>
> On Wed, Nov 2, 2022 at 11:26 AM Jeff Sawatzky  
> wrote:
>
>> Now that protocol buffers 3 has support for optional fields 
>>  which lets you test 
>> whether the field was set or not, are FieldMasks still useful?
>>
>> For instance, when implementing an Update method in gRPC which allows 
>> the client to update only the fields that they pass, should the method take 
>> a message with `optional` fields or a FieldMask? Is it a matter of personal 
>> preference? Or is there a benefit to one of them?
>>
>> We also want to expose the gRPC API as a JSON/HTTP API using either 
>> grpc-gateway or envoy with the grpc_json_transcoder filter. Do these have a 
>> preference with either pattern?
>>
>> I see that Googles AIPs  recommend 
>> FieldMasks for Update methods, but this could have been done before 
>> `optional` was available?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to protobuf+u...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/protobuf/9f8b2b48-66fe-4f97-b822-84402309a5edn%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/c85e19bb-ba91-4450-92e5-92b09d15c3f2n%40googlegroups.com.


Re: [protobuf] Protobuf 3 optional vs FieldMasks

2022-11-03 Thread 'Adam Cozzette' via Protocol Buffers
>From a protobuf perspective, either approach should work, so I think it is
mostly a matter of preference. I think you are right that FieldMasks
predate proto3 optional fields and were originally designed to accommodate
the lack of optional fields in proto3. Now that proto3 has optional fields,
they are a valid alternative to FieldMask.

On Wed, Nov 2, 2022 at 11:26 AM Jeff Sawatzky 
wrote:

> Now that protocol buffers 3 has support for optional fields
>  which lets you test
> whether the field was set or not, are FieldMasks still useful?
>
> For instance, when implementing an Update method in gRPC which allows the
> client to update only the fields that they pass, should the method take a
> message with `optional` fields or a FieldMask? Is it a matter of personal
> preference? Or is there a benefit to one of them?
>
> We also want to expose the gRPC API as a JSON/HTTP API using either
> grpc-gateway or envoy with the grpc_json_transcoder filter. Do these have a
> preference with either pattern?
>
> I see that Googles AIPs  recommend FieldMasks
> for Update methods, but this could have been done before `optional` was
> available?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/9f8b2b48-66fe-4f97-b822-84402309a5edn%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr4MNGCWnx__GO27Zf-1MeAB1hkAV5nyqWnZ4ugHHCEGFg%40mail.gmail.com.


[protobuf] Protobuf 3 optional vs FieldMasks

2022-11-02 Thread Jeff Sawatzky
 

Now that protocol buffers 3 has support for optional fields 
 which lets you test whether 
the field was set or not, are FieldMasks still useful?

For instance, when implementing an Update method in gRPC which allows the 
client to update only the fields that they pass, should the method take a 
message with `optional` fields or a FieldMask? Is it a matter of personal 
preference? Or is there a benefit to one of them?

We also want to expose the gRPC API as a JSON/HTTP API using either 
grpc-gateway or envoy with the grpc_json_transcoder filter. Do these have a 
preference with either pattern?

I see that Googles AIPs  recommend FieldMasks 
for Update methods, but this could have been done before `optional` was 
available?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/9f8b2b48-66fe-4f97-b822-84402309a5edn%40googlegroups.com.