or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication.mdclient.mddns.mdhttp.mdindex.mdmiddleware.mdserialization.md
tile.json

dns.mddocs/

DNS Resolution & Networking

AWS-specific DNS resolution and networking types for advanced connection management and multi-region scenarios. These types enable sophisticated routing, failover, and performance optimization for AWS service connections.

Capabilities

Host Address Types

Core types for representing network addresses and DNS resolution results.

/**
 * Host address type enumeration for DNS record types
 * Specifies IPv4 vs IPv6 addressing for network connections
 */
enum HostAddressType {
  /** IPv6 address record type */
  AAAA = "AAAA",
  /** IPv4 address record type */
  A = "A"
}

/**
 * Host address representation containing resolved network information
 * Result of DNS resolution with full addressing details
 */
interface HostAddress {
  /** Address type (IPv4 or IPv6) */
  addressType: HostAddressType;
  /** Resolved IP address */
  address: string;
  /** Original hostname that was resolved */
  hostName: string;
  /** Optional service name or port information */
  service?: string;
}

Usage Examples:

import { HostAddress, HostAddressType } from "@aws-sdk/types";

// IPv4 address representation
const ipv4Address: HostAddress = {
  addressType: HostAddressType.A,
  address: "52.219.96.24",
  hostName: "s3.amazonaws.com",
  service: "https"
};

// IPv6 address representation
const ipv6Address: HostAddress = {
  addressType: HostAddressType.AAAA,
  address: "2600:9000:234c:7a00:e:74b2:3240:93a1",
  hostName: "s3.amazonaws.com"
};

DNS Resolution Interface

Complete DNS resolver interface for advanced hostname resolution with caching and failure reporting.

/**
 * DNS resolver interface for hostname to IP address resolution
 * Provides advanced features like caching, failure reporting, and multi-address results
 */
interface HostResolver {
  /**
   * Resolve hostname to IP addresses
   * @param args - Resolution arguments containing hostname and options
   * @returns Promise resolving to array of resolved addresses
   */
  resolveAddress(args: HostResolverArguments): Promise<HostAddress[]>;
  
  /**
   * Report failure on a specific address for intelligent routing
   * @param addr - Address that failed to connect
   */
  reportFailureOnAddress(addr: HostAddress): void;
  
  /**
   * Purge cached DNS entries
   * @param args - Optional specific entries to purge, or all if not specified
   */
  purgeCache(args?: HostResolverArguments): void;
}

/**
 * Arguments for DNS resolution operations
 * Specifies what to resolve and resolution preferences
 */
interface HostResolverArguments {
  /** Hostname to resolve */
  hostName: string;
  /** Optional service name for SRV record resolution */
  service?: string;
  /** Optional port number */
  port?: number;
  /** Preferred address family (IPv4 or IPv6) */
  addressFamily?: HostAddressType;
  /** Optional timeout for resolution */
  timeout?: number;
  /** Additional resolution options */
  [key: string]: any;
}

Usage Examples:

import { 
  HostResolver, 
  HostResolverArguments, 
  HostAddress,
  HostAddressType 
} from "@aws-sdk/types";

// Example DNS resolver implementation
class CustomHostResolver implements HostResolver {
  private cache = new Map<string, HostAddress[]>();
  private failedAddresses = new Set<string>();
  
  async resolveAddress(args: HostResolverArguments): Promise<HostAddress[]> {
    const cacheKey = `${args.hostName}:${args.service}`;
    
    // Check cache first
    if (this.cache.has(cacheKey)) {
      const cached = this.cache.get(cacheKey)!;
      // Filter out failed addresses
      return cached.filter(addr => 
        !this.failedAddresses.has(`${addr.address}:${args.port}`)
      );
    }
    
    // Perform DNS resolution
    const addresses = await this.performDnsLookup(args);
    this.cache.set(cacheKey, addresses);
    
    return addresses;
  }
  
  reportFailureOnAddress(addr: HostAddress): void {
    const key = `${addr.address}:${addr.service}`;
    this.failedAddresses.add(key);
    
    // Could implement exponential backoff here
    setTimeout(() => {
      this.failedAddresses.delete(key);
    }, 60000); // Remove from failed list after 1 minute
  }
  
  purgeCache(args?: HostResolverArguments): void {
    if (args) {
      const cacheKey = `${args.hostName}:${args.service}`;
      this.cache.delete(cacheKey);
    } else {
      this.cache.clear();
    }
  }
  
  private async performDnsLookup(args: HostResolverArguments): Promise<HostAddress[]> {
    // Implementation would use Node.js dns module or browser DNS APIs
    // This is a simplified example
    const addresses: HostAddress[] = [];
    
    // Mock resolution results
    if (args.hostName.includes("amazonaws.com")) {
      addresses.push({
        addressType: HostAddressType.A,
        address: "52.219.96.24",
        hostName: args.hostName,
        service: args.service
      });
      
      if (args.addressFamily !== HostAddressType.A) {
        addresses.push({
          addressType: HostAddressType.AAAA,
          address: "2600:9000:234c:7a00:e:74b2:3240:93a1",
          hostName: args.hostName,
          service: args.service
        });
      }
    }
    
    return addresses;
  }
}

// Usage in AWS SDK context
const resolver = new CustomHostResolver();

// Resolve AWS service endpoint
const addresses = await resolver.resolveAddress({
  hostName: "s3.us-east-1.amazonaws.com",
  service: "https",
  port: 443,
  addressFamily: HostAddressType.A // Prefer IPv4
});

console.log("Resolved addresses:", addresses);

// Report connection failure for intelligent routing
if (connectionFailed) {
  resolver.reportFailureOnAddress(addresses[0]);
}

// Clear cache when needed
resolver.purgeCache();

Connection Management

Types for advanced connection management and pooling used with DNS resolution.

/**
 * Connection configuration for establishing network connections
 * Defines parameters for connection establishment and management
 */
interface ConnectConfiguration {
  /** Target hostname */
  hostname: string;
  /** Target port */
  port: number;
  /** Connection timeout in milliseconds */
  connectTimeout?: number;
  /** Socket timeout in milliseconds */
  socketTimeout?: number;
  /** Keep-alive configuration */
  keepAlive?: boolean;
  /** Address family preference */
  family?: number;
  /** Local address to bind to */
  localAddress?: string;
  /** Local port to bind to */
  localPort?: number;
}

/**
 * Connection manager interface for managing network connections
 * Handles connection pooling, reuse, and lifecycle management
 */
interface ConnectionManager {
  /**
   * Acquire a connection for use
   * @param config - Connection configuration
   * @returns Promise resolving to an available connection
   */
  acquire(config: ConnectConfiguration): Promise<any>;
  
  /**
   * Release a connection back to the pool
   * @param connection - Connection to release
   */
  release(connection: any): void;
  
  /**
   * Destroy all connections and clean up resources
   */
  destroy(): void;
}

/**
 * Connection manager configuration options
 * Defines pooling behavior and connection limits
 */
interface ConnectionManagerConfiguration {
  /** Maximum number of connections per host */
  maxConnections?: number;
  /** Maximum number of pending connection requests */
  maxPendingRequests?: number;
  /** Connection idle timeout in milliseconds */
  idleTimeout?: number;
  /** DNS resolver instance */
  hostResolver?: HostResolver;
}

/**
 * Connection pool interface for managing multiple connections
 * Provides efficient connection reuse and resource management
 */
interface ConnectionPool {
  /**
   * Get a connection from the pool
   * @param endpoint - Target endpoint information
   * @returns Promise resolving to pooled connection
   */
  getConnection(endpoint: any): Promise<any>;
  
  /**
   * Return a connection to the pool
   * @param connection - Connection to return
   */
  returnConnection(connection: any): void;
  
  /**
   * Close all connections in the pool
   */
  close(): void;
}

Usage Examples:

import { 
  ConnectConfiguration,
  ConnectionManager,
  ConnectionManagerConfiguration,
  HostResolver 
} from "@aws-sdk/types";

// Configure connection management
const connectionConfig: ConnectionManagerConfiguration = {
  maxConnections: 50,
  maxPendingRequests: 100,
  idleTimeout: 30000, // 30 seconds
  hostResolver: new CustomHostResolver()
};

// Example connection manager usage
class AdvancedConnectionManager implements ConnectionManager {
  private pools = new Map<string, ConnectionPool>();
  private config: ConnectionManagerConfiguration;
  
  constructor(config: ConnectionManagerConfiguration) {
    this.config = config;
  }
  
  async acquire(config: ConnectConfiguration): Promise<any> {
    const poolKey = `${config.hostname}:${config.port}`;
    
    if (!this.pools.has(poolKey)) {
      this.pools.set(poolKey, this.createPool(poolKey));
    }
    
    const pool = this.pools.get(poolKey)!;
    return await pool.getConnection(config);
  }
  
  release(connection: any): void {
    // Return connection to appropriate pool
    const poolKey = this.getPoolKey(connection);
    const pool = this.pools.get(poolKey);
    if (pool) {
      pool.returnConnection(connection);
    }
  }
  
  destroy(): void {
    for (const pool of this.pools.values()) {
      pool.close();
    }
    this.pools.clear();
  }
  
  private createPool(poolKey: string): ConnectionPool {
    // Create and configure connection pool
    return new CustomConnectionPool(this.config);
  }
  
  private getPoolKey(connection: any): string {
    // Extract pool key from connection
    return `${connection.hostname}:${connection.port}`;
  }
}

// Usage with AWS SDK
const connectionManager = new AdvancedConnectionManager({
  maxConnections: 100,
  idleTimeout: 60000,
  hostResolver: resolver
});

// Acquire connection for AWS service
const connection = await connectionManager.acquire({
  hostname: "s3.amazonaws.com",
  port: 443,
  connectTimeout: 5000,
  keepAlive: true
});

// Use connection for requests...

// Release when done
connectionManager.release(connection);