Skip to content

Function: dnsResolve() ​

dnsResolve(hostname): Effect<DiagnosticStep>

Defined in: diagnostics.ts:84

Resolves a hostname to an IP address using DNS lookup.

This function wraps Node's dns.lookup in an Effect for functional error handling. It measures the time taken for DNS resolution and returns diagnostic information.

Parameters ​

hostname ​

Hostname

A validated Hostname branded type

Returns ​

Effect<DiagnosticStep>

An Effect that resolves to a DiagnosticStep with the resolved IP or error

Example ​

typescript
import { Hostname } from '@univ-lehavre/atlas-net';

const step = await Effect.runPromise(dnsResolve(Hostname('example.com')));
if (step.status === 'ok') {
  console.log(`Resolved to ${step.message} in ${step.latencyMs}ms`);
}