Closed bcpeinhardt closed 1 year ago
To make sure I'm understanding correctly, is the idea that your todo_id_gen
gives back a new value each time it's called?
If the answer to my above is correct, I'd imagine you'll want to make an actor to represent your IdGen
logic. You would store the handler in your State, and send a message to get a new id with something like this. That message handler would increment its internal state.
Let me know if I'm mistaken, or you have any questions about that.
Gotcha, I'm super new to OTP so it's time I figured it out (I'm assuming that's what you mean by actor). Basically, the id module has a function that will use the IdGen struct to give back a new Id and a new IdGen, it needs refactoring but it's essentially the same.
Closing this for now, feel free to re-open if needed!
Hey there! I've set up a little todo rest api example. I have an
IdGen
type for generating my ID's, and I'd like to be able to use the updated verison for each new request. It's currently structured likeso the updated state isn't getting used. How would you recommend passing updated state to request handlers?