extend("flow")
extend("net")
extend("json")
extend("sys")
run = (int#delay, int#timeout) => {
start = sys:timestamp_ms()
flow:compose(
flow:drain_async,
flow:stop_when( _ =>
sys:timestamp_ms() > start+timeout
),
flow:chain(row =>
slog(json:encode(row))
),
flow:throttle(delay)
)
}
run(100, 10)(
net:ping([dest:"8.8.8.8"])
)