Re: [protobuf] Extra dot in descriptor data (protoc java)

2021-12-22 Thread 'Venkat Duddu' via Protocol Buffers
Thank you Marc.

When I have leading dot, we are facing issues with schema confluent schema 
registry integration. 

1. We register schema without leading dot.
2. Confluent Schema registry uses the descriptor data to look up schema def 
for a given protobuf message since descriptorData has extra dot, it is 
throwing schema not found exception.

Workaround for now looks like: add leading dot in the schema definition as 
well so that schema def and descriptor data both will have the dot. Not 
sure whether this is the right solution or not, but seems to be working for 
now.

On Wednesday, December 22, 2021 at 11:18:12 AM UTC-8 marc.g...@gmail.com 
wrote:

> IIRC, the leading dot means that the name is absolute rather than 
> relative. I'm not sure it represents an error.
>
> On Wed, 22 Dec 2021, 19:00 'Venkat Duddu' via Protocol Buffers, <
> prot...@googlegroups.com> wrote:
>
>> We are seeing extra dot for external referenced variables in 
>> descriptorData in the generated java class for a given Message.
>>
>> *Message Definition*
>> syntax = "proto3";
>> package com.chegg;
>>
>> import "google/protobuf/struct.proto";
>>
>> message OneGraphRequest {
>> string operation_name = 1;
>> google.protobuf.Struct variables = 2;
>> string query = 3;
>> }
>>
>> *DescriptorData (*java.lang.String[] descriptorData*)* from the 
>> generated Class for *variables* looks like this:
>> "*.google.protobuf.Struct*"
>>
>> It is starting with extra dot (before google), how can we suppress 
>> (remove the extra dot at the begining) it?
>>
>> -- 
>> 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/338c0e38-6c7a-435d-945b-f2e23f8a6979n%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/997e010d-9f4c-463d-8c2a-71bbdfe1ff2cn%40googlegroups.com.


Re: [protobuf] Extra dot in descriptor data (protoc java)

2021-12-22 Thread Marc Gravell
IIRC, the leading dot means that the name is absolute rather than relative.
I'm not sure it represents an error.

On Wed, 22 Dec 2021, 19:00 'Venkat Duddu' via Protocol Buffers, <
protobuf@googlegroups.com> wrote:

> We are seeing extra dot for external referenced variables in
> descriptorData in the generated java class for a given Message.
>
> *Message Definition*
> syntax = "proto3";
> package com.chegg;
>
> import "google/protobuf/struct.proto";
>
> message OneGraphRequest {
> string operation_name = 1;
> google.protobuf.Struct variables = 2;
> string query = 3;
> }
>
> *DescriptorData (*java.lang.String[] descriptorData*)* from the generated
> Class for *variables* looks like this:
> "*.google.protobuf.Struct*"
>
> It is starting with extra dot (before google), how can we suppress (remove
> the extra dot at the begining) it?
>
> --
> 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/338c0e38-6c7a-435d-945b-f2e23f8a6979n%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/CAF95VAxCr%2BfQ1HozrfhyXjBZVB55x_RkashLoNpPKh7%2BkspvNw%40mail.gmail.com.


[protobuf] Extra dot in descriptor data (protoc java)

2021-12-22 Thread 'Venkat Duddu' via Protocol Buffers
We are seeing extra dot for external referenced variables in descriptorData 
in the generated java class for a given Message.

*Message Definition*
syntax = "proto3";
package com.chegg;

import "google/protobuf/struct.proto";

message OneGraphRequest {
string operation_name = 1;
google.protobuf.Struct variables = 2;
string query = 3;
}

*DescriptorData (*java.lang.String[] descriptorData*)* from the generated 
Class for *variables* looks like this:
"*.google.protobuf.Struct*"

It is starting with extra dot (before google), how can we suppress (remove 
the extra dot at the begining) it?

-- 
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/338c0e38-6c7a-435d-945b-f2e23f8a6979n%40googlegroups.com.


[protobuf] Re: Message Definition

2021-12-22 Thread 'Theo Rose' via Protocol Buffers
#1 for achieving "constants" the use of enums and default tag would give 
you what you want, but this is only permitted in proto2
example: //Enums default to their zero value. By not using 0, you ensure a 
message is always explicitly set. 
enum MessageType {
MSG_TYPE_INVALID = 0;
MSG_TYPE_1 = 1;
MSG_TYPE_2 = 2;
}

message MessageOne {
optional MessageType msg_type = 1 [default=MSG_TYPE_1];
optional string name = 2;
}

message MessageTwo {
optional MessageType msg_type = 1 [default=MSG_TYPE_2];
optional string name = 2;
} 
#2 - This can be done by using OneOf fields(Compatible with both proto2 and 
proto3). OneOf might also be able to eliminate your need for constants to 
check for your message types. Both proto2 and proto3 uses the `has` to check which OneOf is being used. example: 
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloResponse) {}
}

// The request message containing MessageOne and MessageTwo.
message HelloRequest {
oneof request_message {
MessageOne msg1 = 1;
MessageTwo msg2 = 2;
}
}

// The response message containing the greetings
message HelloResponse {
optional string message = 1;
}
This will generate code for `HasMsg1` and `HasMsg2`.

On Tuesday, December 21, 2021 at 5:20:13 PM UTC-5 Bob wrote:

> I have many messages that can be sent between 2 processes.  All of these 
> messages have a few things in common.  they all have common 'header' fields 
> that identify what type of message it is, the length of the message, they 
> all have varying length payloads, and they all have a correlation id.  The 
> type of message is 'constant' per message.
>
> I am looking to use proto3, and I'm not seeing any constant functionality 
> - yet.
>
> A couple questions.
> 1) is there a way to define that type constant per message?
> eg - Message1 type=1234
>   Message2 type=
>
> 2) is there a way to define the service method such that I only need to 
> define one method that takes any of the messages that have been defined 
> (similar to java's passing interface type on a method)?
> eg - sendMessage(MyMessageInterface), but in actuality, it can be 
> Message1, Message2, ...  
>
>

-- 
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/d5c47798-a702-4f08-b456-bfbd75cde4afn%40googlegroups.com.