包阅导读总结
1. 关键词:Vapor 5、Swift、Server-Side、Development、Concurrency
2. 总结:Vapor 团队为 Swift 服务器端开发框架 Vapor 推出 Vapor 5,目标是利用 Swift 6 并发能力,进行多项改进,初版计划随 Swift 6 发布。Vapor 5 有诸多主要目标,在 GitHub 上受欢迎,早期版本将随 Swift 6 推出。
3. 主要内容:
– Vapor 服务器端开发框架已推出四年,将推出 Vapor 5
– 旨在利用 Swift 6 并发能力,为未来发展奠基,初版随 Swift 6 发布
– Vapor 5 的主要目标
– 支持全结构化并发的原生 API
– 采用更多现代 Swift 生态包
– 重写 WebSocket 和 MultipartKit API
– Vapor 5 的优势
– 抛弃 EventLoopFuture,使用结构化并发,便于代码理解和 Xcode 诊断
– 利用近年突出的第三方库,如 Swift Service Lifecycle 等
– 迁移到 Swift Foundation 以统一各平台行为
– Vapor 的组件
– 核心包处理路由等
– Fluent 用于创建数据模型
– JWT 处理 JSON Web Tokens
– Leaf 生成 HTML 的模板引擎
– Vapor 在 GitHub 上受欢迎,Vapor 5 早期版将提供全异步栈并移除 EventLoopFuture API
思维导图:
文章来源:infoq.com
作者:Sergio De Simone
发布时间:2024/9/11 0:00
语言:英文
总字数:453字
预计阅读时间:2分钟
评分:88分
标签:Vapor 5,Swift,Swift 6,服务器端开发,并发
以下为原文内容
本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com
Over four years since the launch of its current version, the team behind Swift server-side development framework Vapor is making room for Vapor 5, which aims at leveraging Swift 6 concurrency capabilities and laying the foundations for the framework’s future evolution. An initial alpha release is planned to be ready when Swift 6 is officially released.
Among Vapor 5 main goals are native API support for full structured concurrency, the adoption of more modern packages from the Swift ecosystem, and a full rewrite of the WebSocket and the MultipartKit APIs.
Embracing structured concurrency means Vapor 5 is going to ditch the EventLoopFuture
which was introduced in Vapor 3 and remains at the foundations of Vapor 4 more recent async/await
-based APIs. Instead, Vapor 5 will use structured concurrency from the outset and will not use EventLoopFuture
altogether, thus making it easier to reason about code and being friendlier to Xcode advanced diagnostics for structured concurrency.
Vapor 5 will also take advantage of a few third-party libraries that have become prominent in recent years, including Swift Service Lifecycle, a library to launch and stop services; Swift HTTP Types, a library that provides a common set of representations for HTTP requests and responses; and a new HTTP server based on Hummingbird, which will bring support for gRPC, async body streaming and SSE. Additionally, Vapor 5 will migrate to Swift Foundation a lightweight base layer that replaces the Foundation API delivered with iOS and macOS. This will provide consistent behaviour across all platforms and reduce confusion for multi-platform developers, says the Vapor team.
As a final note about Vapor 5, it will introduce new implementations for the WebSocket and MultipartKit APIs. The main limitation in the current MultipartKit implementation is lack of support for streaming multipart bodies, which can make it hard to work with either very large files, or with APIs like NIOFileSystem. This will be solved by the new implementation in Vapor 5. Similarly, the current Websocket APIs are hard to use in the async-await
world, and the new release will provide an updated, easier-to-use API.
Vapor comprises four main components, including a core package aimed at handling routes, JSON encoding/decoding, and managing HTTP requests; Fluent, that allows you to create data models using noSQL databases; JWT, used to create sign and verify JSON Web Tokens in Swift; and Leaf, a template engine to generate HTML from a simplified syntax.
With over 24k stars on GitHub and almost 250 contributors, Vapor seems to be the most popular choice to build HTTP web apps or APIs in Swift.
As mentioned, an early release of Vapor 5 will be available along with Swift 6, focusing on providing a fully async stack and removing all the EventLoopFuture
APIs.