• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

gRPC, comparison not working with message created in seperate service proto.More Added

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, tried to post with the full code but got flagged as Spam so I'm trying it with the barest of info here. I am trying to write an if loop with this comparison but it isn't working at all, I think because the variables aren't assigning properly. I can't figure out how to debug it as it's a service initialization and us run from the client, which only debugs the client


Here, CapacityService is the service name, Male WC is an initilialization of a room class which was created in a different services proto. The initialization is as follows, the proto will be below that. Again, the room code from the proto comes from a different proto to the service being used




I genuinely have no idea what is wrong and am completely unsure of how to attack the problem. I have tried changing the if line to lots of things, the only thing that worked was 2>1. Any help appreciated

EDIT: I think it's possible everything is initializing as zero, hence the issues. Having a similar problem with a different, much simpler function. Used Bloom RPC to just test the input and modified the code to print out the request and got 0 as opposed to the input. Shown below.



Here, running the non commented out test, when I input  180, Bloom returns zero.
 
Frances Holland
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had to reduce the code in the intended post to the bare minimum to avoid the Spam filter so can add any additions needed below upon request. Given the way this project has been going I will be glued to my PC for the next 60 hours
 
Marshal
Posts: 79177
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

We haven't worked out the “spam” problem, yet, but are still trying.
If you have a nested class with a static getPopulation() method, there is something iffy about that design. Why is MaleWC a nested class in the first place? Why is its population static?
 
Frances Holland
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

We haven't worked out the “spam” problem, yet, but are still trying.
If you have a nested class with a static getPopulation() method, there is something iffy about that design. Why is MaleWC a nested class in the first place? Why is its population static?



Thanks for trying to help with Spam issue. Not a big deal, feel this is a bit of a lost cause.

MaleWC is a nested class (assuming the nested class bit is referring to creating it in the proto and then using it in the class, my syntax is bad) because there are several services that interact with several rooms and the original idea was that if population changed in one service it would be reflected in another. The dreams of mice and men. The goal has been massively scaled back due to how lost I am but that was the original intent. My first attempt was creating Room as it's own proto but I couldn't compile it so I settled with putting it in the most relevant proto.

MaleWC is static because if static is not added to I get the following error on the if clause and on other lines like the following

Cannot make a static reference to the non-static method MaleWC() from the type CapacityService




As for why the original class Room is the way it is, it's a generated class and I can't tell. It has this warning on top and I've been adhering to it

// Generated by the protocol buffer compiler.  DO NOT EDIT!

 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A nested class is a class inside another class or interface. Is the WC regarded as a “part” of CapacityService? Or so intimately related to it that it won't exist separately? If yes, then it is worth considering making it a nested class. Most nested classes are static because they are easier to use as static.
I don't like that error message about “non‑static”; it misleads people into marking something static that shouldn't be. 99% of the time, the correct solution to that error message, which you wouldn't guess from it, is to move the code you are calling something from out of a static contect.
You said MaleWC() was a class; the error message says it is an instance method, which is probably what it ought to be. In which case it should be spelt maleWC(). Please tell us exactly what you are doing; if you don't give us the right information in the question, we can't give you the right answer.

We have a list of company names etc. which have been used in spammy posts; maybe you inadvertently used one of those words. What was the exact error message? What happens if you spell a suspect work wrongly?
 
Marshal
Posts: 4499
572
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are not already familiar with gRPC, I think it would be worth investing a couple of hours (or more) to:
   - define a simple service using a unary call
   - get it to compile with protoc
   - implement the server side and test it using a tool such as grpcurl
   - implement the client side and test end-to-end

After you get that sorted-out, look at streaming client calls, streaming server calls, and bi-direction streaming calls if needed in your project.

It is not always obvious how to use the codec code generated by protoc and adding streaming to the mix can make things really challenging when you are starting out.
 
If you want to look young and thin, hang around old, fat people. Or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic