0

I am using GRPCv3 on node.js

I have a .proto file with the following message:

message ProductAvailabilityWithRatesResponse {
    // How many slots are available for this day/time. Mandatory.
    int32 capacity = 1;
    // Date for when this product is available. Mandatory.
    Date date = 2;
    // When does this event start? Unset if this product does not support times.
    Time time = 3;
    // When does a pickup for this product start? Unset if this product does not support times or pickups.
    Time pickupTime = 4;
    // Rates with prices. Mandatory (should at least have one entry).
    repeated RateWithPrice rates = 5;
}

on the server using console.log i see this output:

{ capacity: 1,
  date: { year: 2019, month: 7, day: 1 },
  rates: [ { rateId: 1, pricePerPerson: [Object] } ],
  time: { hour: 9, minute: 0 } }

and on a client using node.js too:

{ rates:
   [ { rateId: '1',
       pricePerPerson: [Object],
       pricingOptions: 'pricePerPerson' } ],
  capacity: 0,
  date: { year: 2019, month: 7, day: 1 },
  time: { hour: 9, minute: 0 },
  pickupTime: null }

but another person using a java client tells me that he sees:

2019-06-26 10:59:39,442  ← getProductAvailability::grpc response {date { year: 2019 month: 7 day: 1 } time { hour: 9 } rates { rateId: "1" pricePerPerson { pricingCategoryWithPrice { pricingCategoryId: "30" price { currency: "EUR" amount: "145" } } pricingCategoryWithPrice { pricingCategoryId: "31" price { currency: "EUR" amount: "150" } } } }}

where capacity is not set. If it's value is 1 and not 0, everything works well everywhere. Is it possible? How can i force the server to output the value? I already tried using capacity = parseInt(capacity)

user1014351
  • 437
  • 1
  • 5
  • 16
  • What is gRPCv3? Also, what exactly is the source of these objects you are printing out? – murgatroid99 Jun 26 '19 at 20:24
  • The node.js library is: https://github.com/grpc/grpc-node as in: https://grpc.io/grpc/node/ The server is started with: ` function main() { var server = new grpc.Server(); server.addService(hello_proto.PluginApi.service, { GetProductAvailability:GetProductAvailability, }); } ` and the server response is like this: ` function GetProductAvailability(call) { pr = {}; pr.capacity = result[index].numero; pr.capacity = parseInt(pr.capacity + 0); pr.date = {year: d.getFullYear(), month: (d.getMonth()+1), day:d.getDate()}; .... call.write(pr); call.end(); } ` – user1014351 Jun 27 '19 at 07:58
  • OK, I know what the Node gRPC library is, but there is no version 3 of that library. Can you add that code to the question itself, and also include the `console.log` lines that are outputting the output we are looking at? – murgatroid99 Jun 27 '19 at 15:21

0 Answers0