Re: [protobuf] Compiler forward-compatibility

2019-01-21 Thread Nikita Vorobyev
Thanks!

On Saturday, 19 January 2019 03:34:42 UTC+3, Adam Cozzette wrote:
>
> Yes, absolutely. The schemas do not even have to be exactly the same, and 
> in fact protobuf is designed to allow the schema to evolve in a compatible 
> way. The most important thing is just to never reuse the same field number 
> with incompatible types.
>
> On Fri, Jan 18, 2019 at 2:30 AM Nikita Vorobyev  > wrote:
>
>> Hi all!
>>
>> Is protobuf compiler-neutral? Will I be able to deserialize message with 
>> code, generated by compiler of version X, if this message was serialized 
>> with compiler of version Y? Version of syntax and schemes will be obviously 
>> the same on both sides.
>>
>> Thanks in advance.
>>
>> Nikita.
>>
>> -- 
>> 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 post to this group, send email to prot...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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 post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] How to use oneOf as a type?

2019-01-21 Thread Brian Palmer
oneof is a property of the message that the fields are in; it's not really
a type of its own. Instead, you could do something like

message Event {
  required int32 event_id = 1;
  optional EventSpecifics specifics = 2;
}

message EventSpecifics {
  oneof EventType {
 optional FooEvent foo_event = 1;
 optional BarEvent bar_event = 2;
  }
}



On Thu, Jan 10, 2019 at 9:16 AM Suhas N  wrote:

> Given a message that looks like this,
>
> message Event {
> required int32 event_id = 1;
>
> oneof EventType {
> FooEvent foo_event = 2;
> BarEvent bar_event = 3;
> BazEvent baz_event = 4;
> }
> }
>
>
> I want to define another map which uses the EventType oneof as a type.
> Precisely, I want to define something like this
>
> message Sample {
> map someMap = 1;
> }
>
>
> But, this is not working. I get the error that
>
>
> PROTOC FAILED: "Event.EventTypeCase" is not defined.
>
> How can I use the oneof as a type?
>
> --
> 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 post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


Re: [protobuf] Avoiding code duplication / copy paste

2019-01-21 Thread Derek Perez
I think the general spirit of protobuf is to assume not every field needs
to be filled out on a message just because you reference it in a new
context. Additionally, you could do request validation to ensure they
aren't set if you're worried people might misunderstand.

On Mon, Jan 21, 2019, 11:42 AM  wrote:

> Hello,
>
> I have been working with protobuf for a few months. I've noticed a very
> bad pattern: I had to copy and paste data types again and again.
>
> For example, let's say we have the `User` type with `username`, `mail` and
> `name`. Now, we want to add a `SearchUserRequest`, which is the same as
> `User` but its fields are inside a `oneof`. Now, we'll have to copy all of
> `User`'s fields to `SearchUserRequest`'s `oneof`. That causes  code
> duplication which leads to duplicate messages and a pain to maintain.
>
> My idea was to add a special macro-message which builds a new message on
> top of the other one. For example (Pseudo code):
> mutate User as SearchUserRequest {
> # Disallow searching by email.
> remove email;
> }
>
>
>
> Please let me know if you think the same, if there is another way to solve
> this problem, and what do you think about my solution.
> Shmuel.
>
> --
> 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 post to this group, send email to protobuf@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.


[protobuf] Avoiding code duplication / copy paste

2019-01-21 Thread shmuelhazan0
Hello, 

I have been working with protobuf for a few months. I've noticed a very bad 
pattern: I had to copy and paste data types again and again.

For example, let's say we have the `User` type with `username`, `mail` and 
`name`. Now, we want to add a `SearchUserRequest`, which is the same as 
`User` but its fields are inside a `oneof`. Now, we'll have to copy all of 
`User`'s fields to `SearchUserRequest`'s `oneof`. That causes  code 
duplication which leads to duplicate messages and a pain to maintain. 

My idea was to add a special macro-message which builds a new message on 
top of the other one. For example (Pseudo code):
mutate User as SearchUserRequest {
# Disallow searching by email. 
remove email;
}



Please let me know if you think the same, if there is another way to solve 
this problem, and what do you think about my solution.
Shmuel. 

-- 
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 post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.