Skip to content

Commit 8d2140e

Browse files
authored
remove references to unix domain sockets (#96)
The `unix_gram` module was removed from the standard library in 2011, for Windows portability reasons, so this library will not support Unix Domain Sockets. nodejs/node#29339 There is a third-party library `unix-dgram`, which offers this functionality, but it introduces some complications, and we want this library to be as low- friction as possible. Thus, we will not adopt this module. https://github.com/bnoordhuis/node-unix-dgram This state of affairs is similar to the Java thin-client, where the JVM does not support Unix Domain Sockets until 16+: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/net/UnixDomainSocketAddress.html).
1 parent a60d60a commit 8d2140e

5 files changed

Lines changed: 16 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nflx-spectator",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"license": "Apache-2.0",
55
"homepage": "https://github.com/Netflix/spectator-js",
66
"author": "Netflix Telemetry Engineering <netflix-atlas@googlegroups.com>",

src/config.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,23 @@ export class Config {
1818
* * `stderr` - Write metrics to standard error.
1919
* * `stdout` - Write metrics to standard output.
2020
* * `udp` - Write metrics to the default spectatord UDP port. This is the default value.
21-
* * `unix` - Write metrics to the default spectatord Unix Domain Socket. Useful for high-volume scenarios.
22-
* * `file:///path/to/file` - Write metrics to a file or a Unix Domain Socket.
21+
* * `file:///path/to/file` - Write metrics to a file.
2322
* * `udp://host:port` - Write metrics to a UDP socket.
2423
*
2524
* The output location can be overridden by configuring an environment variable SPECTATOR_OUTPUT_LOCATION
2625
* with one of the values listed above. Overriding the output location may be useful for integration testing.
26+
*
27+
* Unix Domain Sockets are not supported in this library, because Node.js removed the `unix_dgram` package
28+
* from the standard library in 2011, as a part of portability concerns for Windows.
29+
*
30+
* https://github.com/nodejs/node/issues/29339
31+
*
32+
* There is a third-party `unix-dgram` library, but it contains C++ source code, which complicates the build,
33+
* and it introduces synchronous calls in the context of callbacks. We want this library to be as low-friction
34+
* as possible, so we will not adopt this package. If you need UDS support, use the C++, Go, or Python libraries
35+
* instead.
36+
*
37+
* https://github.com/bnoordhuis/node-unix-dgram
2738
*/
2839

2940
location: string;

src/writer/file_writer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {fileURLToPath} from "node:url";
55

66
export class FileWriter extends Writer {
77
/**
8-
* Writer that outputs data to a file descriptor, which can be stdout, stderr, a unix domain
9-
* socket, or a regular file.
8+
* Writer that outputs data to a file descriptor, which can be stdout, stderr, or a regular file.
109
*/
1110

1211
private readonly _location: string;

src/writer/new_writer.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {StdoutWriter} from "./stdout_writer.js";
1010
export type WriterUnion = FileWriter | MemoryWriter | NoopWriter | StderrWriter | StdoutWriter | UdpWriter;
1111

1212
export function is_valid_output_location(location: string): boolean {
13-
return ["none", "memory", "stderr", "stdout", "udp", "unix"].includes(location) ||
13+
return ["none", "memory", "stderr", "stdout", "udp"].includes(location) ||
1414
location.startsWith("file://") ||
1515
location.startsWith("udp://");
1616
}
@@ -38,9 +38,6 @@ export function new_writer(location: string, logger?: Logger): WriterUnion {
3838
} else {
3939
writer = new UdpWriter(location, parsed.hostname, Number(parsed.port), logger);
4040
}
41-
} else if (location == "unix") {
42-
location = "file:///run/spectatord/spectatord.unix";
43-
writer = logger == undefined ? new FileWriter(location) : new FileWriter(location, logger);
4441
} else if (location.startsWith("file://")) {
4542
writer = logger == undefined ? new FileWriter(location) : new FileWriter(location, logger);
4643
} else if (location.startsWith("udp://")) {

test/config.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ describe("Config Tests", (): void => {
6363
assert.equal("stderr", get_location("stderr"));
6464
assert.equal("stdout", get_location("stdout"));
6565
assert.equal("udp", get_location("udp"));
66-
assert.equal("unix", get_location("unix"));
6766
assert.equal("file://", get_location("file://"));
6867
assert.equal("udp://", get_location("udp://"));
6968
});

0 commit comments

Comments
 (0)