This week's giveaway is in the Spring forum.
We're giving away four copies of liveProject: Protecting User Data with Spring Security and OAuth2 and have Laurentiu Spilca on-line!
See this thread for details.
Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

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: 72595
317
  • 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: 72595
317
  • 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: 3489
494
Android 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.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic