protocol-buffers

Reachability and International Roaming

痴心易碎 提交于 2019-12-10 10:44:10
问题 I am using the Reachability class from Apple to determine whether or not data or wifi is available. However, a user (with a U.S. iPhone) is testing the app in another country and he is seeing the following error while trying to access the MapKit. Console In my research on this error, I have found that PBRequester is ProtocolBuffer . 2012-10-15 21:16:00.921 WrightsCS App[24239:907] PBRequester failed with Error Error Domain=kCFErrorDomainCFNetwork Code=-1018 "International roaming is currently

Dropwizard and Protocol Buffers by example

こ雲淡風輕ζ 提交于 2019-12-10 10:27:47
问题 Please note: Although this question specifically mentions Dropwizard, I believe anyone with Jersey/JAX-RS experience should be able to answer this question, as I would imagine Dropwizard is just following Jersey/JAX-RS conventions under the hood. I have a Dropwizard service that reds/writes in JSON and works beautifully. I would like to now switch it to read/write binary data (to minimize network bandidth). I see there is the Dropwizard-Protobuf lib but I have a few concerns about

Sending protocol buffers via REST

为君一笑 提交于 2019-12-10 10:13:54
问题 I am trying to implement protocol buffers for client/server using REST. I am still a bit confused if I need to send protocol buffers request in byte format? I mean, in my client code, do I need to serialize object to byte array? For example protoRequest.build.toByteArray() And in the server, do I need to c @POST @Consumes("application/octet-stream") public byte[] processProtoRequest(byte[] protoRequest) { ProtoRequest.Builder request = ProtoRequest.newBuilder(); request.mergeFrom(protoRequest

Proto3 setting value equal to default is not recognised in runtime

一世执手 提交于 2019-12-10 10:13:46
问题 Proto3 is not as strict as Proto2 , and there are no required or optional fields, there are no custom default values. Given the following definition... message Order { enum Side { BID = 0; ASK = 1; } int64 time = 1; double price = 2; double volume = 3; Side side = 4; } There are default values for any of those fields, after all now there are no rules of what you must or must not provide before you .build() your object. So the default for time is 0 , price is 0.0 and side is BID , if you print

Google Protocol Buffers, how to handle multiple message-Types?

非 Y 不嫁゛ 提交于 2019-12-10 09:43:49
问题 Is it possible to get the Type of the serialized Protocol Buffer message? I have this example option java_outer_classname="ProtoUser"; message User { required int32 id = 1; required string name = 2; required string firstname = 3; required string lastname = 4; required string ssn= 5; } message Address { required int32 id = 1; required string country = 2 [default = "US"];; optional string state = 3; optional string city = 4; optional string street = 5; optional string zip = 6; } In Java I have

Making shared_ptr lose ownership of memory

狂风中的少年 提交于 2019-12-10 09:23:27
问题 I have a shared_ptr<MyProto> which I pass around. Eventually, in certain situations, I want pass the raw pointer to a function which then becomes the memory owner. In those cases the shared_ptr isn't responsible anymore for freeing the memory because the function I call took ownership. How do I get the shared_ptr to lose ownership? The reason I want to have the shared_ptr lose ownership is that I want to use protocol buffer's AddAllocated functionality which takes an already allocated pointer

Read value of enum extension in protocol buffer

爷,独闯天下 提交于 2019-12-09 18:38:26
问题 I just asked this question and have resolved to write an extension for enum values in my protocol buffer. However I am having an extremely difficult time actually reading the values back, even with this simple .proto file: package test; import "google/protobuf/descriptor.proto"; extend google.protobuf.EnumValueOptions { optional string abbr = 54321; } message Person { required string name = 1; required int32 id = 2; optional string email = 3; enum PhoneType { MOBILE = 0 [(abbr)="Mobile ph"];

XXX_* type in generated *.pb.go file

霸气de小男生 提交于 2019-12-09 18:01:21
问题 I'm working on a tutorial about gRPC. When I generated the .pb.go file, I'm getting some XXX_* type in my struct. This is my consignment.proto file: syntax = "proto3"; package go.micro.srv.consignment; service ShippingService { rpc CreateConsignment(Consignment) returns (Response) {} } message Consignment { string id = 1; string description = 2; int32 weight = 3; repeated Container containers = 4; string vessel_id = 5; } message Container { string id = 1; string customer_id = 2; string origin

Are protobuf messages compatible across versions of protobuf

戏子无情 提交于 2019-12-09 16:23:57
问题 I started building an app with protobuf 2.2.0 as it was the latest. Now I'm considering upgrading to protobuf 2.4.0a which is the latest. If I do so will the messages generated by one version of the app still be readable by the other version for the same schema? Or would I be breaking something? 回答1: That should be fine. Version 2.1.0 introduced packed repeated fields, but I don't believe there have been any wire format changes since then. 来源: https://stackoverflow.com/questions/4963620/are

Google Protocol Buffers (protobuf) in Python3 - trouble with ParseFromString (encoding?)

允我心安 提交于 2019-12-09 13:01:32
问题 I've got Google Protocol buffers 80% working in Python3. My .proto file works, I'm encoding data, life is almost good. The problem is that I can't ParseFromString the result of SerializeToString. When I print SerializeToString it looks like what I'd expect, a fairly compact binary representation (preceded by b'). My guess is that perhaps this is a difference in the way Python2 and Python3 handle strings. The putput of SerializeToString is Bytes, not a string. Printed output of