feat: user-defined readiness checks via readyOn#188
Open
mikenomitch wants to merge 8 commits intomainfrom
Open
feat: user-defined readiness checks via readyOn#188mikenomitch wants to merge 8 commits intomainfrom
mikenomitch wants to merge 8 commits intomainfrom
Conversation
# Conflicts: # src/lib/container.ts
commit: |
Collaborator
Author
|
Noting stuff for reviewers to look at:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a way to define arbitrary readiness hooks that must resolve before fetch requests are proxied to the container.
Today, the de-facto readiness check is "are the declared ports listening?". That's baked into
startAndWaitForPortsand there's no way to express "also wait for/healthto return 200" or "wait for this warmup promise" without writing imperative code aroundcontainerFetch. This PR turns port-waiting into one of several composable checks.Usage:
Main changes:
ReadinessChecktype:(container, options?) => Promise<unknown>. Checks run in parallel viaPromise.all; any rejection fails readiness.readyOn?: ReadinessCheck[]. When undefined, defaults are derived fromdefaultPort/requiredPorts— preserving today's behaviour.addReadinessCheck(check)andsetReadinessChecks(checks).setReadinessChecks([])opts out entirely.portResponding(port)andpathHealthy(path, port?).Container.waitForPath({ path, portToCheck, ... })— polling analogue ofwaitForPortthat requires 2xx.startAndWaitForPortsinternals now delegate to the readiness-check machinery. Explicitportsargs still behave as before; no args runsreadyOn(or the derived default).Tests live in
examples/core-tests— added aReadyOnContainerwhose/healthendpoint returns 503 for the first 1.5s, and a test that verifiespathHealthypolls until healthy before the proxied fetch returns 200.Notes:
Promises in the list aren't supported; wrap as() => myPromise. Class-body initializers fire at construction, so eager promises would start before the container is known.AGENTS.md; changeset added (minor bump).