Commit Graph

44 Commits

Author SHA1 Message Date
Rafael Cepeda 9224dc5159
Added buffer pool to NIOTSConnectionChannel (#236)
Added buffer pool to NIOTSConnectionChannel for reading messages.

### Motivation:

In order to avoid creating a new `ByteBuffer` for every single message
read from the channel, we decided to reuse the
`NIOPooledRecvBufferAllocator` type from NIOCore to leverage a pool of
buffers.

### Modifications:

Used the buffer allocation mechanism provided by the
`NIOPooledRecvBufferAllocator` to reuse and adapt previously created
receive buffers.

### Result:

Channel reads can now reuse previously created buffers, avoiding
unnecessary overhead by creating new buffers every single time.
2025-05-13 18:44:21 +01:00
Rick Newton-Rogers 7114435533
Drop Swift 5.9 (#235)
Motivation:

Swift 5.9 is no longer supported, we should bump the tools version and
remove it from our CI.

Modifications:

* Bump the Swift tools version to Swift 5.10
* Remove Swift 5.9 jobs where appropriate in main.yml, pull_request.yml

Result:

Code reflects our support window.
2025-05-05 12:13:58 +01:00
Gus Cairo 9eb2ebde13
Fix missing strict concurrency error (#231)
Current strict concurrency checks don't work consistently in Xcode. This
PR adds an additional flag (`-Xfrontend`) to our set of strict
concurrency flags to make sure nothing has been missed when building. It
also fixes an additional error uncovered after adding it.
2025-04-09 15:08:12 +01:00
Gus Cairo 92bb536b7e
Strict concurrency for NIOTransportServices and tests (#228) 2025-04-02 10:54:00 +01:00
Rick Newton-Rogers 888a842a61
Only apply standard swift settings on valid targets (#225)
Only apply standard swift settings on valid targets. The current check
ignores plugins but that is not comprehensive enough.
2025-03-07 15:07:17 +00:00
Rick Newton-Rogers 3221911857
Enable MemberImportVisibility check on all targets (#220)
Enable MemberImportVisibility check on all targets. Use a standard
string header and footer to bracket the new block for ease of updating
in the future with scripts.
2024-12-13 15:08:51 +01:00
Rick Newton-Rogers c73112efc0
Migrate CI to use GitHub Actions. (#213)
### Motivation:

To migrate to GitHub actions and centralised infrastructure.

### Modifications:

Changes of note:
* Adopt swift-format using rules from SwiftNIO. Modified so that it
ignores `NoAssignmentInExpressions` in some `XCTAssert` functions.
* Remove scripts and docker files which are no longer needed

### Result:

Feature parity with old CI.
2024-10-28 09:51:24 +00:00
Cory Benfield fc398db673
Revert "Don't depend on NIOFoundationCompat in NIOTransportServices on Linux (#209)" (#210)
This reverts commit 40ffcdef46 in PR #209.

Unfortunately, Swift's behaviour around imports tends to be somewhat
"leaky". In this case, the leak is that the dependency on the
Package.swift allows downstream projects to import `NIOFoundationCompat`
without needing to actually specify the package dependency. This has
affected Hummingbird, which we noticed on our internal integration
testing functionality:

```
hummingbird/Sources/Hummingbird/Codable/JSON/JSONCoding.swift:18:8: error: no such module 'NIOFoundationCompat'
import NIOFoundationCompat
       ^
```

cc @Joannis @adam-fowler for the Hummingbird report.

Unfortunately, we can't make this change until we're willing to use a
semver major to achieve it. There may be some argument for doing that
now, as the semver major will be very cheap to adopt across the
ecosystem. But we'll need to do this in a considered way.

@Cyberbeni please feel free to reopen your PR targetting main, where we
can discuss whether this is worth issuing a semver major for.
2024-10-14 09:01:34 +01:00
Benedek Kozma 40ffcdef46
Don't depend on NIOFoundationCompat in NIOTransportServices on Linux (#209)
Don't depend on NIOFoundationCompat in NIOTransportServices on Linux

### Motivation:

I'm trying to build a small utility tool based on mqtt-nio which depends
on NIOTransportServices. I noticed that NIOTransportServices depends on
NIOFoundationCompat on all platforms but only imports it where the
Network framework is available. Removing this dependency on non-Apple
platforms allows us to not import Foundations, significantly reducing
the size of the build product when using the Swift Static Linux SDK.

### Modifications:

This PR and a similar one to mqtt-nio.

### Result:

Hello world docker image depending on mqtt-nio went from 169MB to 85MB.
2024-10-09 12:07:41 +02:00
George Barnett dbace16f12
We no longer require the docc plugin (#208)
Motivation:

Swift Package Index builds our docs for us and will automatically insert
the dependency.

Modifications:

- Remove the docc-plugin dependency

Result:

Fewer dependencies
2024-10-03 18:09:39 +01:00
George Barnett 4a0fad7658
Raise minimum Swift version to 5.8 (#199) 2024-03-11 09:32:56 +00:00
Franz Busch 2f6ba3d83c
Fix availability guards and compiler warnings (#193)
# Motivation
We missed a few availability guards in our tests which caused errors when compiling for older Darwin platforms. Additionally the latest NIO release deprecated a few APIs on `NIOAsyncChannel`.

# Modification
This PR adds the missing guards and fixes all of the deprecation warnings.

# Result
We should build on all supported platforms again
2023-11-24 14:49:34 +00:00
Franz Busch ebf8b9c365
Add new typed async bootstrap APIs back and drop SPI (#191)
* Revert "Back out SPI(AsyncChannel) changes"

This reverts commit 33d2b2993f.

* Add new typed async bootstrap APIs back and drop SPI

# Motivation
We just merged the removal of the `AsyncChannel` SPI in NIO and can now add back the new APIs in transport services as well.

# Modification
This PR brings back the previous SPI and promotes it to API.

# Result
New typed async bootstraps API for `NIOTransportServices`.

* George review
2023-10-25 14:09:26 +01:00
Rick Newton-Rogers 0561bee80c
Bump minimum Swift version to 5.7 (#189)
Motivation:

Now that Swift 5.9 is GM we should update the supported versions and
remove 5.6

Modifications:

* Update `Package.swift`
* Delete the 5.6 docker compose file and make a 5.10 one
* Update docs

Result:

Remove support for Swift 5.6, add 5.10
2023-10-04 10:18:36 +01:00
Franz Busch f73f69faf7
Adopt latest AsyncChannel SPI changes (#183)
# Motivation
We had some breaking changes in the NIO AsyncChannel SPI which we have to adapt here.

# Modification
This PR updates to the latest AsyncChannel SPI

# Result
No more warnings and errors when building.
2023-08-09 10:17:34 +01:00
Franz Busch fbc49d892b
Adopt latest SPI(AsyncChannel) changes (#181)
# Motivation
We introduced some breaking SPI(AsyncChannel) changes in NIO that we have to adopt here.

# Modification
This PR adopts the latest `NIOProtocolNegotiationResult` APIs. Additionally, it also drops all bind/connect methods on the bootstraps that are specific to protocol negotiation or `NIOAsyncChannel`.

# Result
Green CI on `main` and alignment between `NIOPosix` and `NIOTS.
2023-07-26 07:48:49 -07:00
Franz Busch 01fc0ae7e5
Adopt the `NIOAsyncChannel.Configuration` (#179)
# Motivation
We introduced a new configuration struct for `NIOAsyncChannel` to make handling and configuring it easier.

# Modification
This PR adopts the new APIs.

# Result
Less boilerplate in our bootstrap methods
2023-07-11 16:34:56 +01:00
Franz Busch ee0c7ffcd6
Async methods for `NIOTSListenerBootstrap` and `NIOTSConnectionBootstrap` (#178)
* Async methods for `NIOTSListenerBootstrap` and `NIOTSConnectionBootstrap`

# Motivation
We want to support async bootstrapping with all our bootstraps.

# Modification
This PR adds support for the `NIOTSListenerBootstrap` and `NIOTSConnectionBootstrap`. It also adds the three variants of methods to it (abstract output, `NIOAsyncChannel` based and protocol negotiation based)

# Result
We now support asynchronous interaction with the `NIOTSListenerBootstrap` and `NIOTSConnectionBootstrap`

* Use protocolHandlers properly

* Update NIO version

* code review

* REview

* Doc indention
2023-07-06 15:17:56 +02:00
David Nadoba 41f4098903
Use underscore version of `NIOPreconcurrencySendable` to silence warning (#173)
### Motivation
`swift-nio` has deprecated `NIOPreconcurrencySendable` in `2.51.0`. Removing the protocol conformance would be an API breaking change. Keeping the conformance is low cost and not worth the risk.

### Changes
- replace `NIOPreconcurrencySendable` with underscore version `_NIOPreconcurrencySendable`

### Result
We compile again with the latest `swift-nio` release without warnings
2023-04-25 15:00:26 +02:00
Cory Benfield b39e53ad42
Replace Lock with NIOLock (#157)
Motivation:

Lock has been deprecated in favour of NIOLock. Warnings aren't great.

Modifications:

- Replace Lock with NIOLock
- Update the minimum required NIO version to 2.42.0.

Result:

Everything builds cleanly
2022-09-27 13:48:00 +01:00
David Nadoba c2e373fec5
Adopt `Sendable` (#155)
* Adopt `Sendable`

* Workaround Swift 5.4 compiler bug
2022-08-31 16:22:32 +01:00
Cory Benfield 4e02d9cf35
Use Docc for documentation (#154)
Motivation

Documentation is nice, and we can help support users by providing useful
clear docs.

Modifications

Add Docc to 5.6 and later builds
Make sure symbol references work
Add overview docs

Result

Nice rendering docs
2022-07-29 15:02:01 +01:00
David Nadoba 94645c8fcd
Use `swift-atomics` instead of `NIOAtomics` (#153) 2022-07-07 17:50:28 +01:00
Fabian Fett 1a4692acb8
Fix warnings, that appeared after requiring Swift 5.4 (#142) 2022-04-21 09:12:31 -07:00
Fabian Fett b559a7303a
Drop support for Swift 5.2 and 5.3 (#141)
As outlined in a [Swift forums post in November ’21](https://forums.swift.org/t/swiftnio-swift-version-support/53232), SwiftNIO will only support the latest non-patch Swift release and the 2 immediately prior non-patch versions.

- drop support for Swift 5.2 and 5.3. 
- update CI for Swift 5.4 to run on bionic instead of focal to ensure that we still test bionic. 
- add a CI job for Swift 5.7
2022-04-20 08:54:39 +02:00
Cory Benfield e7f5278a26
Clean up imports and dependencies. (#130)
Motivation:

With NIO 2.32.0 we broke the core NIO module up into modules that split
apart the POSIX layer and the core abstractions. As a result, this
package no longer needs to express a hard dependency on the POSIX layer.

Modifications:

- Rewrote imports of NIO to NIOCore.
- Added NIOEmbedded imports where necessary in tests.
- Note that the main package still _depends_ on NIO, which is necessary
  for backwards-compatibility reasons. This dependency is unused.

Result:

No need to use NIOPosix.
2021-09-14 10:06:42 +01:00
George Barnett 5fd5ba4d3e
Use non-deprecated API for removing handlers (#125)
Motivation:

`removeHandlers(channel:)` was deprecated in NIO 2.32.0.

Modifications:

- Raise minimum required NIO version to 2.32.0
- Use `removeHandlers(pipeline:)`

Result:

We don't use deprecated API.
2021-08-17 18:01:25 +01:00
David Evans 39587bcecc
Update NIO to 2.30 (#123) 2021-06-23 14:16:15 +01:00
David Evans 0aecfe8b3a
Remove Swift 5.0 and 5.1 support, and add CI config (#122)
* Setup CI and update Package

* Rename sanity to soundness

* Apply suggestions from code review

Co-authored-by: Cory Benfield <lukasa@apple.com>

* Fix nightly docker config

Co-authored-by: Cory Benfield <lukasa@apple.com>
2021-06-23 08:57:00 +01:00
Johannes Weiss 47fddadf83
stop publishing the executable products (#119) 2021-06-08 14:04:45 +01:00
George Barnett 657537c2cf
Add support for syncOptions to NIOTSListenerChannel and NIOTSConnectionChannel (#117)
Motivation:

NIO 2.27.0 added optional support for synchronous channel options.
NIOTSListenerChannel and NIOTSConnectionChannel should support this.

Modifications:

- Add synchronous options for NIOTSConnectionChannel and
  NIOTSListenerChannel
- Avoid an allocation in 'getOption' for each channel if the caller is
  already on the right event loop by using 'makeSucceededFuture'
- Remove a no longer used internal function and an already dead private
  helper

Result:

- Support for sync options and fewer allocations
2021-03-16 08:38:47 +00:00
Peter Adams cd49a10c4f
Directly support the allowLocalEndpointReuse channel option (#82)
Motivation:

The NetworkFramework directly supports the concept of allowLocalEndPointReuse. Currently to get through the nio system, this is mapped to the SO_REUSEADDR option.

Now there is a shorthand option for this, it is sad to map from allowLocalEndPointReuse to SO_REUSEADDR and back again.

Modifications:

Add a new NIOTS channel option for this setting.
Set the underlying based on any of new setting, reuseAddr or reusePort.
Add a override to interpret the shorthand option directly into the new option.
Add shorthand options for client with tests of equivalence to long options.

Result:

Behaviour is identical but we can feel happier that the option mapping is less confusing.
2020-07-01 14:51:31 +01:00
Johannes Weiss 46cc01e461
universal bootstrap (#69) 2020-03-24 15:57:31 +00:00
Cory Benfield c7f06384dc Adopt NIOAtomic (#67)
Motivation:

We deprecated Atomic because we made a new, better one. We should use
it.

Modifications:

Replaced all use of Atomic with NIOAtomic.

Result:

Better performance, fewer compiler warnings.
2019-12-10 12:35:02 +00:00
Cory Benfield e30bf63ea1 Namespace ChannelOptions. (#61)
Motivation:

In NIO 2.9.0 we moved all first-party `ChannelOption` types into their
own namespace. That was a good idea, but NIOTS uses them too and so it
now encounters build warnings. Additionally, NIOTS defines its own
`ChannelOption`s, and so should namespace those as well.

Modifications:

- Updated the code to use the namespaced `ChannelOption` types.
- Namespaced our own.

Result:

More namespacing.
2019-10-23 17:26:25 -07:00
George Barnett 3d0713dc43 Annotate code with availability attributes (#42)
* Annotate code with availability attributes

Motivation:

It was not possible to import NIOTS into a project where
Network.framework was not supported by all deployment targets.

Modifications:

All NIOTS code, where applicable, was annotated with availability
attributes.

Result:

It is possible for application developers to import NIOTS on platforms
which do not support Network.framework without a compile time error.
2019-05-10 19:02:02 +01:00
Johannes Weiss a1374e9d5e
use SwiftNIO 2.0.0 (#32) 2019-03-26 09:17:14 +00:00
Cory Benfield 501197f000 Correctly avoid branch dependency. (#31)
Motivation:

When entering convergence we incorrectly specified a branch dependency
for something that is actually a tag.

Modifications:

- Remove branch dependency, use from: instead.

Result:

Users can use this repo!
2019-03-25 09:44:58 +00:00
Johannes Weiss 1d0cb1040e
don't retain everything until connect timeout expires (#30)
Motivation:

Previously we would use the combination of DispatchQueue.asyncAfter and
a DispatchWorkItem for the connect timeout. If the connection succeeded
we would just cancel the DispatchWorkItem. Unfortunately that will still
keep everything that's captured in the DispatchWorkItem alive until the
deadline has come (because DispatchWorkItem is just a dumb wrapper over
a closure).

Modifications:

use a DispatchSource of type timer source instead.

Result:

- we won't keep the ELG/EL/Channel/... alive until at least the connect
  timeout expires.
- fixes #28
2019-03-22 15:40:02 +00:00
Cory Benfield e1685ae770 Prepare for convergence. (#27)
Motivation:

Once every few thousand years, an event called syzygy (or "convergence")
occurs in our solar system. When these events occur, the fabric of spacetime
becomes thin, allowing reflections of a possible future to appear in our
reality.

This gives a few brave souls the opportunity to experience a future: a
possibility of the way the universe may one day be. But be warned: to
toy with causality is to risk unbearable pain and suffering. Only the
bravest of souls should look too closely at these shadows of the future.

Modifications:

- Chose a firm anchor point in the SwiftNIO timeline.
- Removed the braces that kept time travellers safe.
- Said a quiet prayer.

Result:

Opportunity.
2019-03-15 14:48:05 +00:00
Johannes Weiss 4587afdf46 port to latest NIO 2 APIs (#20)
Motivation:

Compiling code is good so let's make it compile again with the latest
NIO APIs.

Modifications:
- made NIOTS use `_NIO1APIShims`
- clicked 'Fix All' a couple of times to adjust the API

Result:
Code compiles again
2019-01-22 15:38:13 +00:00
Johannes Weiss 9fa52bd443 use to NIO 2 (from master branch) and Swift 5 (#18)
Motivation:

SwiftPM from Swift 5.0 brings targets that only support certain systems
which is really handy for this package as it only support macOS 10.14+
and iOS/tvOS 12+

Modifications:

- made use of the Swift 5.0 manifests which can have restrictions on the
  supported platforms
- adapted to NIO 2

Result:

- better development story
- using the latest & greatest
2019-01-18 13:03:21 +00:00
Cory Benfield a9cece8a6d
Support preconditionInEventLoop. (#11)
Motivation:

In SwiftNIO 1.11 we shipped improved interfaces for Channels to support
asserting being in the event loop. This is necessary because Dispatch
provides no non-precondition way to 100% guarantee that you are on a
specific queue, which is a requirement for accurate behaviour of
inEventLoop.

Modifications:

- Added an implementation of preconditionInEventLoop.
- Changed all assertions to use new interface.
- Required NIO 1.11.

Result:

Accurate assertions
2018-11-06 17:44:41 +00:00
Cory Benfield 6475881aea Initial commit 2018-07-18 17:11:24 +01:00