@systemfsoftware/effect-readiness
v1.0.0
Published
Effect-native readiness waits — TCP, HTTP, and log conditions over a port mapping, with driver ports, staged dial evidence, and a loopback conformance suite.
Maintainers
Readme
@systemfsoftware/effect-readiness
Composable readiness probes and condition polling for Effect applications, containers, and micro-VMs.
Installation
pnpm add @systemfsoftware/effect-readinessFeatures
- Protocol Agnostic: Wait for TCP port connectivity, HTTP endpoint health (
2xxresponses), or stdout/stderr log stream patterns. - Pure Core / Imperative Shell: Decoupled workflow decisions (
resolveProbe,evaluateProbe) and pure schemas with effectful cell-based execution (awaitCondition). - Platform Separation: Pluggable network dialing and stream reading through the
HostProberandLogSourceservice contracts. Built-inNodeHostProberusing@effect/platform-node. - Interruption & Resource Safety: Clean socket disposal with prompt release upon check completion or timeout.
Usage
import { Readiness } from '@systemfsoftware/effect-readiness'
import { Effect, Layer } from 'effect'
const target = Readiness.target([
{ guest: 8080, host: '127.0.0.1', hostPort: 32768 },
])
.withTimeout(10_000)
.withPoll(100)
// Wait for TCP port connectivity
const checkTcp = target.awaitCondition(Readiness.Wait.forTcp(8080))
// Wait for HTTP endpoint readiness
const checkHttp = target.awaitCondition(Readiness.Wait.forHttp('/healthz', 8080))
// Wait for stdout/stderr log line pattern
const checkLog = target.awaitCondition(Readiness.Wait.forLog('server listening on 8080'))
// Execute with built-in Node driver and a provided LogSource
const program = checkHttp.pipe(
Effect.provide(
Layer.merge(
Readiness.NodeHostProber.layer,
Layer.succeed(Readiness.LogSource, {
entries: Effect.succeed(['booting', 'server listening on 8080']),
}),
),
),
)