refactor: Provide API to stop listener programatically#4860
Conversation
8c74fa5 to
0c7dea1
Compare
|
I'm not a fan of exposing internal APIs just for tests - that means we're shipping code that we don't actually need. Is it a requirement to test this from hspec? Can't we observe the same thing in an IO test? |
Me neither but in this particular case, I'd say there is more to it. The direct reason for this change is to be able to test from
This is a longer discussion started here: #4668 (comment) Testing in Answering directly: no, there is no requirement to test from |
0c7dea1 to
a191f8d
Compare
Note: we're already doing this for the postgrest/src/PostgREST/SchemaCache.hs Lines 171 to 173 in 127490e I've been thinking, couldn't we do these points of failure/testing based on That would allow us to not ship the testing code in the binaries, we would only inject the sleeps (and other things) during testing via a callback. |
a191f8d to
0384435
Compare
eeb776d to
193e210
Compare
193e210 to
49941fb
Compare
I looked at this from a perspective of "what would I do from non-hspec tests, for example pytest, to start/stop the listener?". It seems like |
I believe it is not - there is no code that would stop/start listener thread upon config reload. If it is marked as such in the docs it is a documentation issue. |
Interesting, I was going by the docs only. Maybe we can fix the code instead of the documentation then, to make it reloadable? |
Yeah it's a docs issue. I remember deciding against it because if we allow users to disable the LISTEN in-db then they:
So I don't think we should allow disabling the LISTEN via in-db config. Thoughts? |
|
This was not about in-db, but just about basic reloading. The docs say: I believe we should implement it exactly like this, if that's not already the case. |
|
Right, my bad, got confused.
Agree in making it reloadable by unix signal. Opened #4894 |
49941fb to
d694d94
Compare
This change introduces possibility to stop listener thread programatically. It is a prerequisite for HSpec tests starting the listener as they have to be able to stop it when cleaning up.
d694d94 to
187c134
Compare
Then let's do it here, if we already have the basic pieces in place. I think we should:
|
|
@mkleczek Why was this closed? |
DISCLAIMER:
This commit was authored entirely by a human without the assistance of LLMs.
This change introduces possibility to stop listener thread programatically. It is a prerequisite for HSpec tests starting the listener as they have to be able to stop it when cleaning up.