From 7c163dcd9ebf71a7f484d503a1108c03d9e34010 Mon Sep 17 00:00:00 2001 From: Raphael Hiesgen Date: Wed, 30 Jul 2025 16:01:02 +0100 Subject: [PATCH 1/2] Address sendable warnings Motivation: Builds with newer Swift versions fail because the warnings are escalalated to errors. Modifications: * Make Encoder conform to Sendable. * Fix Sendable issue in TestServer. Result: The project builds without warnings. --- Sources/StatsdClient/StatsdClient.swift | 2 +- Tests/StatsdClientTests/TestServer.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/StatsdClient/StatsdClient.swift b/Sources/StatsdClient/StatsdClient.swift index 2508ac8..9730f2f 100644 --- a/Sources/StatsdClient/StatsdClient.swift +++ b/Sources/StatsdClient/StatsdClient.swift @@ -447,7 +447,7 @@ private final class Client: @unchecked Sendable { return bootstrap.bind(host: self.address.protocol == .inet6 ? "::" : "0.0.0.0", port: 0) } - private final class Encoder: ChannelOutboundHandler { + private final class Encoder: ChannelOutboundHandler, Sendable { public typealias OutboundIn = Metric public typealias OutboundOut = AddressedEnvelope diff --git a/Tests/StatsdClientTests/TestServer.swift b/Tests/StatsdClientTests/TestServer.swift index e06ebb2..46443a2 100644 --- a/Tests/StatsdClientTests/TestServer.swift +++ b/Tests/StatsdClientTests/TestServer.swift @@ -36,7 +36,7 @@ final class TestServer: @unchecked Sendable { func connect() -> EventLoopFuture { let bootstrap = DatagramBootstrap(group: self.eventLoopGroup) .channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1) - .channelInitializer { channel in channel.pipeline.addHandler(Aggregator(delegate: self.store)) } + .channelInitializer { channel in channel.pipeline.addHandler(Aggregator(delegate: { self.store(address: $0, value: $1) })) } return bootstrap.bind(host: self.host, port: self.port).map { _ in () } } @@ -57,12 +57,12 @@ final class TestServer: @unchecked Sendable { } } - class Aggregator: ChannelInboundHandler { + final class Aggregator: ChannelInboundHandler, Sendable { typealias InboundIn = AddressedEnvelope - let delegate: (SocketAddress, String) -> Void + let delegate: @Sendable (SocketAddress, String) -> Void - init(delegate: @escaping (SocketAddress, String) -> Void) { + init(delegate: @escaping @Sendable (SocketAddress, String) -> Void) { self.delegate = delegate } From 0a9d1145ebc36126bd0e69e549d1df68bc8fee9c Mon Sep 17 00:00:00 2001 From: Raphael Hiesgen Date: Wed, 30 Jul 2025 16:20:07 +0100 Subject: [PATCH 2/2] Formatting --- Tests/StatsdClientTests/TestServer.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/StatsdClientTests/TestServer.swift b/Tests/StatsdClientTests/TestServer.swift index 46443a2..1650b91 100644 --- a/Tests/StatsdClientTests/TestServer.swift +++ b/Tests/StatsdClientTests/TestServer.swift @@ -36,7 +36,9 @@ final class TestServer: @unchecked Sendable { func connect() -> EventLoopFuture { let bootstrap = DatagramBootstrap(group: self.eventLoopGroup) .channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1) - .channelInitializer { channel in channel.pipeline.addHandler(Aggregator(delegate: { self.store(address: $0, value: $1) })) } + .channelInitializer { channel in + channel.pipeline.addHandler(Aggregator(delegate: { self.store(address: $0, value: $1) })) + } return bootstrap.bind(host: self.host, port: self.port).map { _ in () } }