import type { ClusterLogger, ClusterTransport, ClusterTransportDescription } from './types.js'; /** * Every local IPv4 address the group should be joined on, loopback FIRST. * * Loopback is not an optimization, it is the same-host case working at all. * Measured on a Linux host with one ethernet interface: a datagram sent on the * LAN interface with IP_MULTICAST_LOOP set was not delivered to ANY local * socket, not even the sender's own, while the identical exchange over * 127.0.0.1 delivered to every process that had joined there. Two goodvibes * processes on one machine is the most common way an install ends up * double-consuming, so relying on the kernel's default interface choice would * have left the primary case silently broken. * * Joining several interfaces means a peer reachable over more than one path * can receive the same datagram twice. That is expected and handled: the * election drops a datagram whose sequence number it has already seen. */ export declare function resolveMulticastInterfaces(): string[]; export interface UdpClusterTransportOptions { readonly port: number; readonly multicastGroup: string; /** `host:port` or bare `host` entries; a bare host uses `port`. */ readonly peers: readonly string[]; readonly logger: ClusterLogger; } interface ResolvedPeer { readonly host: string; readonly port: number; } export declare class UdpClusterTransport implements ClusterTransport { private readonly options; private socket; /** Interface addresses the group was successfully joined on. */ private joined; /** * Serializes sends. IP_MULTICAST_IF is a property of the SOCKET, not of an * individual datagram, so two concurrent sends could otherwise swap the * outgoing interface out from under each other. */ private sendChain; private readonly peers; constructor(options: UdpClusterTransportOptions); describe(): ClusterTransportDescription; start(onMessage: (raw: string) => void): Promise; /** * Fan a datagram out: once per joined interface to the group, plus once to * each static unicast peer. * * Sends are chained rather than run in parallel because switching the * outgoing multicast interface mutates socket state, see `sendChain`. */ send(raw: string): Promise; private sendTo; stop(): Promise; } /** Parse `cluster.peers`, skipping entries that are not usable addresses. */ export declare function parsePeers(entries: readonly string[], defaultPort: number): ResolvedPeer[]; export {}; //# sourceMappingURL=udp-transport.d.ts.map