Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need for a wait_for helper #207

Closed
jeckel opened this issue Nov 30, 2023 · 4 comments
Closed

Need for a wait_for helper #207

jeckel opened this issue Nov 30, 2023 · 4 comments

Comments

@jeckel
Copy link
Contributor

jeckel commented Nov 30, 2023

Hi there,

When I'm working with docker container for example, I often need to wait that a container is ready (healthy) before processing any other action.

We can think of a helper like this :

/**
 * @param callable(): bool $callback
 * @param int $timeout Maximum number of seconds to wait before throwing a TimeoutException
 * @param int $interval Interval in second between calls to the $callback function
 * @throw TimeoutException
 */
function wait_for(callable $callback, int $timeout = 10, int $interval = 1): void;

If you think it's a good feature, I can try a PR

@jeckel
Copy link
Contributor Author

jeckel commented Nov 30, 2023

Or maybe it can return a boolean instead of throwing an Exception ?

@TheoD02
Copy link
Contributor

TheoD02 commented Nov 30, 2023

Hello,

That could be cool ! I use this pattern too for waiting docker container, or for waiting HTTP service on certain port (+ payload if necessary) to be accessible.

Make this type of helper (docker, network…) as shared castor files in a specific repo when import functions from remote will be OK and merged should be cool :)

@pyrech
Copy link
Member

pyrech commented Nov 30, 2023

I think this is something interesting to add to Castor, so I'm +1 for this. Let's wait for others' feedback 🙂

@lyrixx
Copy link
Member

lyrixx commented Dec 19, 2023

Good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants