Skip to content

Commit

Permalink
socket sink: rename unix mode to unix_stream, add unix alias for comp…
Browse files Browse the repository at this point in the history
…atibility
  • Loading branch information
jpovixwm committed Jan 7, 2025
1 parent a0d1ca1 commit 2fa827e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/sinks/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ pub enum Mode {

/// Send over a Unix domain socket (UDS), in stream mode.
#[cfg(unix)]
Unix(UnixMode),
#[serde(alias = "unix")]
UnixStream(UnixMode),

/// Send over a Unix domain socket (UDS), in datagram mode. Unavailable on macOS.
/// Send over a Unix domain socket (UDS), in datagram mode.
/// Unavailable on macOS, due to send(2)'s apparent non-blocking behavior,
/// resulting in ENOBUFS errors which we currently don't handle.
#[cfg(unix)]
#[cfg_attr(target_os = "macos", serde(skip))]
UnixDatagram(UnixMode),
Expand Down Expand Up @@ -138,7 +141,7 @@ impl SinkConfig for SocketSinkConfig {
config.build(transformer, encoder)
}
#[cfg(unix)]
Mode::Unix(UnixMode { config, encoding }) => {
Mode::UnixStream(UnixMode { config, encoding }) => {
let transformer = encoding.transformer();
let (framer, serializer) = encoding.build(SinkType::StreamBased)?;
let encoder = Encoder::<Framer>::new(framer, serializer);
Expand Down Expand Up @@ -167,7 +170,7 @@ impl SinkConfig for SocketSinkConfig {
Mode::Tcp(TcpMode { encoding, .. }) => encoding.config().1.input_type(),
Mode::Udp(UdpMode { encoding, .. }) => encoding.config().input_type(),
#[cfg(unix)]
Mode::Unix(UnixMode { encoding, .. }) => encoding.config().1.input_type(),
Mode::UnixStream(UnixMode { encoding, .. }) => encoding.config().1.input_type(),
#[cfg(unix)]
Mode::UnixDatagram(UnixMode { encoding, .. }) => encoding.config().1.input_type(),
};
Expand Down Expand Up @@ -353,7 +356,7 @@ mod test {
let mut receiver = CountReceiver::receive_lines_unix(out_path.clone());

let config = SocketSinkConfig {
mode: Mode::Unix(UnixMode {
mode: Mode::UnixStream(UnixMode {
config: UnixSinkConfig::new(out_path),
encoding: (None::<FramingConfig>, NativeJsonSerializerConfig).into(),
}),
Expand Down
16 changes: 10 additions & 6 deletions website/cue/reference/components/sinks/base/socket.cue
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ base: components: sinks: socket: configuration: {
}
framing: {
description: "Framing configuration."
relevant_when: "mode = \"tcp\" or mode = \"unix\" or mode = \"unix_datagram\""
relevant_when: "mode = \"tcp\" or mode = \"unix_stream\" or mode = \"unix_datagram\""
required: false
type: object: options: {
character_delimited: {
Expand Down Expand Up @@ -453,10 +453,14 @@ base: components: sinks: socket: configuration: {
description: "The type of socket to use."
required: true
type: string: enum: {
tcp: "Send over TCP."
udp: "Send over UDP."
unix: "Send over a Unix domain socket (UDS), in stream mode."
unix_datagram: "Send over a Unix domain socket (UDS), in datagram mode. Unavailable on macOS."
tcp: "Send over TCP."
udp: "Send over UDP."
unix_datagram: """
Send over a Unix domain socket (UDS), in datagram mode.
Unavailable on macOS, due to send(2)'s apparent non-blocking behavior,
resulting in ENOBUFS errors which we currently don't handle.
"""
unix_stream: "Send over a Unix domain socket (UDS), in stream mode."
}
}
path: {
Expand All @@ -465,7 +469,7 @@ base: components: sinks: socket: configuration: {
This should be an absolute path.
"""
relevant_when: "mode = \"unix\" or mode = \"unix_datagram\""
relevant_when: "mode = \"unix_stream\" or mode = \"unix_datagram\""
required: true
type: string: examples: ["/path/to/socket"]
}
Expand Down

0 comments on commit 2fa827e

Please sign in to comment.