Questions tagged [protobuf-3]

Protocol buffers version 3 - a new language design that is not backward compatible with previous versions.

23 questions
13
votes
1 answer

Polymorphism in Protocol Buffers 3

The current design I am refactoring some exiting API code that returns a feed of events for a user. The API is a normal RESTful API, and the current implementation simply queries a DB and returns a feed. The code is long and cumbersome, so I've…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
13
votes
2 answers

Protobuf3: String validation with regex

I have been using Protobuf3 to define a PB message: syntax = "proto3"; package vioozer_protobuf; message Update { string sensor_id = 1; ... } In my system, sensors have a unique id format (a-la SENSOR-1342r43) that can easily be validated with…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
7
votes
1 answer

The right way to send generic data types with protobuf3 in C#/.NET

I'm developing an application using a plugins architecture and I want to send objects between client and server without knowing the type of the object being sent. Is there a way to send generic data type ? According to Microsoft pages, the Any field…
Vonkel.
  • 306
  • 3
  • 12
5
votes
1 answer

How to store time in protobuf 3

I have this struct in golang struct File { name string creatation_time time.Time } How do I write it in protobuf3 ?
thanhpk
  • 3,900
  • 4
  • 29
  • 36
4
votes
1 answer

Repeated Int32Value in protobuf3 (nullable int array)

I have the following protobuf message protocol: message TestMsg { int32 int = 1; google.protobuf.Int32Value nullable_int = 2; repeated google.protobuf.Int32Value nullable_int_array = 3; // Runtime fail } protoc compiles it fine and in C# all…
maloo
  • 685
  • 1
  • 6
  • 16
4
votes
1 answer

Using protbuf3, how can I express the type 'Map string (Maybe CustomType)'?

I am trying to share a large dictionary/map between a client and a service. I need to be able to bidirectionally set values, and delete values from the dictionary/map without passing the entire map back and forth each time. I know I can create a map…
timthelion
  • 2,636
  • 2
  • 21
  • 30
4
votes
1 answer

Deserialize Protobuf 3 bytearray in python

How to read Protobuf message through bytearray response as string? I tried looking up Protobuf library. https://developers.google.com/protocol-buffers/docs/reference/python/google.protobuf.message-pysrc#Message.MergeFrom When I tried mergeFrom ,…
nevihs
  • 991
  • 1
  • 12
  • 23
3
votes
1 answer

How to serialize default values in nested messages in Protobuf

As the title states I have a protobuf message with another message inside it like this: syntax = "proto3"; message Message { message SubMessage { int32 number = 1; } SubMessage subMessage = 1; } My example.json is empty…
Marv
  • 273
  • 1
  • 5
  • 14
3
votes
4 answers

Protobuf and Python: How to add messages to "repeatable Any" field?

I have a proto message: syntax = "proto3"; import "google/protobuf/any.proto"; message Task { repeated google.protobuf.Any targets = 1; // ... } message Target { string name = 1; // ... } How should I add Target messages into…
Prisacari Dmitrii
  • 1,985
  • 1
  • 23
  • 33
3
votes
1 answer

how to store time.duration in protobuf3

in proto file... syntax = "proto3"; import "google/protobuf/duration.proto"; message aaaResponse{ google.protobuf.Duration min = 2; } ... will auto generate *duration.Duration how to change the proto file to get time.Duration
halle
  • 31
  • 1
  • 2
3
votes
1 answer

Efficient message field setting in Python Protobuf

I am using Protobuf (v3.5.1) in a Python project I'm working on. My situation can be simplified to the following: // Proto file syntax = "proto3"; message Foo { Bar bar = 1; } message Bar { bytes lotta_bytes_here = 1; } # Python…
Michał
  • 2,202
  • 2
  • 17
  • 33
3
votes
0 answers

GRPC nested arrays (protobuf3)

Im using GRPC with proto3 and im trying to represent the following JSON in messages: menus: [ { name: "Mains", contents: [ { title: "Steaks", contents: [ …
mwild
  • 1,483
  • 7
  • 21
  • 41
2
votes
0 answers

Why can't I use protoc generate Python3 object which has an Any type field via --python3_out, only --python_out works

I created a proto file RpcCmd.proto, and defined one field with type google.protobuf.Any, when I tried to generate a Python3 object file with cmd protoc --python3_out=./gen RpcCmd.proto it failed with error Traceback (most recent call last): File…
Tony Jiang
  • 21
  • 1
2
votes
1 answer

no valid method for accessing or setting values in protobuf class

I have been struggling with Google protobufs lately. I have written a proto file called Button.proto. Here are its contents: syntax = "proto3"; package robotjoystick; message Button { string name = 1; int32 id = 2; uint32 state = 3; } I…
robotsfoundme
  • 418
  • 4
  • 18
2
votes
1 answer

Protobuf3: What happens when all fields of an object happen to be set to default value

My understanding with proto3 is that for scalars, there is no way to distinguish whether the message sender set a field to the default value or didn't set the field at all because default values aren't sent over the wire. That is, the hasField call…
gunit
  • 3,700
  • 4
  • 31
  • 42
1
2