Closed qcn closed 3 years ago
I don't quite understand the rationale for this, because the attribute you're checking, @stopped
, only gets set to true if you have explicitly called close
to shut down the client permanently. So 1. there's no way the client could have stopped itself without you already knowing about it, and 2. there is no restarting from that state.
The use-case is that we check this in a loop - if there's an error, we call close
to shut down the client, but that's a response to an event. In the loop, if the client has been shut down, we spin up a new one. We could do this by setting a flag in our error handler and looping on that instead, but by exposing the stopped state of the client we link that behaviour explicitly to the client rather than an external flag.
@qcn I see. I have no problem with adding this method, but I think it's a bit confusing to call it is_alive?
when "alive" isn't a word that's used anywhere else in the API. Could you change it to is_closed?
(and have it return the value of @stopped
rather than the opposite) to clarify that it's referring to the state caused by close
?
Actually how about just closed?
- Ruby's naming conventions don't require "is" for boolean getters.
@eli-darkly Great! I've made the change requested, thank you for the discussion! :)
Version 2.1.0 has been released with this change.
@eli-darkly Thank you so much!
We used this gem for monitoring and found that it was useful to expose the aliveness status of the client to check if we needed to restart it.