NIOKit + CodableKit


(Tanner) #1

We're starting work on two new packages that will debut with Vapor 4. NIOKit and CodableKit. The goal of these packages is to break out a lot of utilities Vapor has developed over the past two years in our Core repo. This repo has grown quite large and contains a lot of things we think would be useful to the Server community as a whole, not tied to Vapor.

NIOKit

This repo will contain useful conveniences for working with SwiftNIO. Some examples are things like mapping over a Future collection's items.

let users: Future<[User]> = ...
users.mapEach { user in
    print(user.id)
}

Some other conveniences for working with types like ByteBuffer will likely go here. The idea is to upstream as much as possible to SwiftNIO itself, but things that are out of scope for NIO itself may find a home here.

The only dependency to this package will be SwiftNIO itself.

Check out some of the ideas we have so far, and feel free to add your own here:

CodableKit

Vapor has accumulated a ton of useful code for working with Swift's Codable protocols. This includes things like Dummy decoders, basic CodingKey impls, and Encoder/Decoder conformance helpers. It also includes Vapor's codable-based Reflection mechanism which is the backbone of our ORM, Fluent.

We have a number of improvements planned to this code, and we want to make sure that this code can benefit the entire community without being coupled to Vapor or SwiftNIO. The only dependency to this package is Foundation.

The first PR has been put up to add in an updated reflection mechanism. This new algorithm is less code and has an improved runtime: O(n^2) -> O(n).

Check it out, and feel free to add your own ideas / feature requests here:

note: These packages will be moved from vapor-community to vapor at some point soon.