Ir al contenido
Español

NodeAddress

Esta página aún no está disponible en tu idioma.

Defined in: src/cluster/NodeAddress.ts:5

A node in the cluster is identified by host + port + system name. Stringified as system@host:port.

new NodeAddress(systemName, host, port): NodeAddress

Defined in: src/cluster/NodeAddress.ts:6

string

string

number

NodeAddress

readonly host: string

Defined in: src/cluster/NodeAddress.ts:8


readonly port: number

Defined in: src/cluster/NodeAddress.ts:9


readonly systemName: string

Defined in: src/cluster/NodeAddress.ts:7

compareTo(other): number

Defined in: src/cluster/NodeAddress.ts:21

Ordering used by the leader election: lexicographic on the string form.

NodeAddress

number


equals(other): boolean

Defined in: src/cluster/NodeAddress.ts:14

NodeAddress

boolean


toJSON(): NodeAddressData

Defined in: src/cluster/NodeAddress.ts:25

NodeAddressData


toString(): string

Defined in: src/cluster/NodeAddress.ts:12

string


static fromJSON(data): NodeAddress

Defined in: src/cluster/NodeAddress.ts:50

Rebuild an address from its wire form.

The declared parameter type is a promise the wire cannot keep: every caller on the receive path hands this whatever JSON.parse produced. A port that arrives as the string "2552" is the sharp case — toString() renders it identically to the number, so it keys every map the same way, but equals() compares === and never matches. A node that reads its own address back in that shape stops recognising itself, permanently (#571).

Throwing rather than coercing is deliberate: a well-behaved peer never sends this, so there is no shape worth repairing, and the transport’s frame guard rejects malformed addresses before they get here. This is the backstop for the paths that reach it another way.

port is checked as a positive integer, not a TCP port — the same rule ClusterOptionsValidator states and for the same reason: under InMemoryTransport the port is a synthetic node discriminator (tests use five-digit values), and an address is transport-agnostic. Whether a port is dialable is TcpTransport’s business.

NodeAddressData

NodeAddress


static parse(s): NodeAddress

Defined in: src/cluster/NodeAddress.ts:64

Parse a string of the form system@host:port.

string

NodeAddress