Does fp-ts have any functionality to do a while loop (stack safe) with timeout. Like tail recursion, Y Combinator or something. I have seen ChainRec, but there aren't really any documentation besides functions signatures.
Exact issue I have:
I need to wait for the database (postgres) to start up in docker container. I decided to determine that by writing a loop that scans the output of docker logs
for a specific regex each n
milliseconds, and the loop stops if the regex is matched or timeout has been reached. Timeout, regex and n
are all arguments.
Or maybe it's better to do docker logs --follow
and process STDIN stream. But I don't know how to do it functionally, either.
P.S. Trying to execute something in database instead of scanning for logs doesn't work. Since postgres for some reason becomes available during its boot sequence and then becomes unavailable again before it finally completely starts, leaving a message in the log.