Rails8

杰瑞发布于2024-10-05

Beyond plenty fast enough for most applications. As a bonus, Solid Cable retains the messages sent in the database for a day by default, which may ease debugging of tricky live update issues.
对于大多数应用程序来说,速度已经足够快了。作为额外的好处,Solid Cable默认情况下会将数据库中发送的消息保留一天,这可能会简化棘手的实时更新问题的调试。
Solid Cable has been created by Nick Pezza from Working Not Working.
Solid Cable是由Nick Pezza从Working Not Working创作的。
Solid Cache:
Solid Cache.
Solid Cache replaces the need for either Redis or Memcached for storing HTML fragment caches in particular. In addition to getting rid of the accessory service dependency, it also always for a vastly larger and cheaper cache thanks to its use of disk storage rather than RAM storage. This means your cache can live longer and cover even more requests out the plank of the 95th or 99th percentile. Additionally, this cache can be encrypted and managed by an explicit retention limit (like 30 or 60 days). Making it easier to live up to modern privacy policies and expectations.
Solid Cache取代了Redis或Memcached来存储HTML片段缓存的需要。除了摆脱对附件服务的依赖外,由于使用了磁盘存储而不是RAM存储,它还总是需要更大、更便宜的缓存。这意味着您的缓存可以存活更长时间,并覆盖第95或99百分位之外的更多请求。此外,此缓存可以通过明确的保留限制(如30或60天)进行加密和管理。使遵守现代隐私政策和期望变得更加容易。
Solid Cache has been in production at Basecamp for well over a year where it stores 10 terabytes of data, enables a full 60-day retention window, and cut the P95 render times in half after it’s introduction.
Solid Cache在Basecamp已经投入生产一年多了,它存储了10TB的数据,实现了完整的60天保留期,并在推出后将P95渲染时间缩短了一半。
Solid Cache was created by Donal McBreen from 37signals.
Solid Queue:
Solid Queue Solid Queue replaces the need for not just Redis, but also a separate job-running framework, like Resque, Delayed Job, or Sidekiq, for most people. For high-performance installations, it’s built on the new FOR UPDATE SKIP LOCKED mechanism first introduced in PostgreSQL 9.5, but now also available in MySQL 8.0 and beyond. For more modest needs, it also works with SQLite, which makes it ideal for that no-dependency path to the first HELLO WORLD dopamine hit you get from seeing your work in production right away.
Solid Queue Solid Queue不仅取代了Redis,还取代了大多数人对单独的作业运行框架的需求,如Resque、Delayed job或Sidekiq。对于高性能安装,它建立在PostgreSQL 9.5中首次引入的新的For UPDATE SKIP LOCKED机制之上,但现在MySQL 8.0及更高版本也提供了该机制。对于更温和的需求,它也适用于SQLite,这使其成为您在生产中立即看到您的工作时获得第一个HELLO WORLD多巴胺的无依赖路径的理想选择。
Solid Queue can either run as a puma plugin, which is the default on a single-server installation, or by using the new bin/jobs command for starting a dedicated dispatcher. It’s possible to run multiple dispatchers dealing with dedicated queues according to bespoke performance tuning all with a flexible configuration scheme that asks for no tweaking out of the box, but gives you all the dials once you need it.
Solid Queue既可以作为puma插件运行,这是单服务器安装的默认配置,也可以使用新的bin/jobs命令启动专用调度器。可以根据定制的性能调优运行多个调度程序来处理专用队列,所有这些都有一个灵活的配置方案,不需要开箱即用,但一旦需要,就会给你所有的拨号。
It has virtually all the features you could want from a modern job queuing system. Including robust concurrency controls, failure retries and alerting, recurring job scheduling, and so much more. In HEY, it replaced no less than 6(!) different Resque gems, as the one integrated solution.
它几乎具备现代作业排队系统所需的所有功能。包括强大的并发控制、故障重试和警报、重复作业调度等等。在HEY中,它取代了不少于6(!)种不同的Resque宝石,成为一个集成解决方案。
Solid Queue has been meticulously developed within the pressures of a real production environment over the last 18 months, and today it’s running 20 million jobs per day for HEY alone at 37signals.
Solid Queue是在过去18个月里,在真实生产环境的压力下精心开发的,如今,仅HEY就在37signals上每天运行2000万个作业。
Solid Queue was created by Rosa Gutiérrez from 37signals.
Solid Queue was created by Rosa Gutiérrez from 37signals.
Ready:
Getting SQLite ready for production.
正在为SQLite的生产做好准备。
On top of the trifecta of Solid adapters that makes it possible for SQLite to power Action Cable, Rails.cache, and Active Job, a bunch of work has gone into making the SQLite adapter and Ruby driver suitable for real production use in Rails 8.
除了使SQLite能够为Action Cable、Rails.cache和Active Job供电的Solid适配器之外,还进行了大量工作,使SQLite适配器和Ruby驱动程序适合Rails 8中的实际生产使用。
At 37signals, we’re building a growing suite of apps that use SQLite in production with ONCE. There are now thousands of installations of both Campfire and Writebook running in the wild that all run SQLite. This has meant a lot of real-world pressure on ensuring that Rails (and Ruby) is working that wonderful file-based database as well as it can be.
37signals正在构建一套越来越多的应用程序,这些应用程序在生产环境中使用SQLite和ONCE。现在有成千上万的Campfire和Writebook在野外运行,它们都运行SQLite。这意味着在确保Rails(和Ruby)尽可能好地运行基于文件的数据库方面,现实世界面临着很大的压力。
Through proper defaults like WAL and IMMEDIATE mode. Special thanks to Stephen Margheim for a slew of such improvements and Mike Dalessio for solving a last-minute SQLite file corruption issue in the Ruby driver.
replace:
Replacing Sprockets with Propshaft.
用传动轴更换链轮。
But Rails 8 is not just about the better deployment story and database-backed adapters. We’re also making Propshaft the new default asset pipeline. Propshaft a is dividend from the mission to focus on #NOBUILD as the default path in Rails 7 (and offloading more complicated JavaScript setups to bun/esbuild/vite/etc). As the new asset pipeline it replaces the old Sprockets system, which hails from all the way back in 2009. A time before JavaScript transpilers and build pipelines as we know them today existed. And long, long before we could imagine browsers with stellar JavaScript implementations, import maps, and no constraints from many small files thanks to HTTP/2.
但是Rails 8不仅仅是更好的部署故事和数据库支持的适配器。我们还将Propshaft作为新的默认资产管道。Propshaft a是专注于#NOBUILD作为Rails 7默认路径的任务的红利(并将更复杂的JavaScript设置卸载到bun/esbuild/vite/etc)。作为新的资产管道,它取代了早在2009年就出现的旧Sprockets系统。在我们今天所知道的JavaScript转译器和构建管道存在之前的一段时间。很久以前,我们就可以想象浏览器具有出色的JavaScript实现、导入映射,并且由于HTTP/2而没有来自许多小文件的约束。
It’s a great example of the need to occasionally pull a fresh sheet of paper and consider a familiar problem from first principles again. And it turns out, in our new 'NOBUILD' world, the asset pipeline only needs to do two primary things: Provide a load path for assets and stamp them with digests to allow for far-future expiry. That’s basically it. Sprockets did a million other things than that, many of them in a way that had long since fallen out of favor, and from a state of disrepair that had few contributors willing or able to help remedy it.
这是一个很好的例子,说明需要偶尔拿出一张新纸,再次从第一性原理中考虑一个熟悉的问题。事实证明,在我们新的“NOBUILD”世界中,资产管道只需要做两件主要的事情:为资产提供加载路径,并用摘要标记它们,以允许在遥远的未来到期。基本上就是这样。Sprockets还做了无数其他事情,其中许多事情早已不受欢迎,而且由于年久失修,很少有贡献者愿意或能够帮助补救。
So we thank Sprockets for 15 years of service, but the future of the asset pipeline in Rails is called Propshaft. And it’s now the default for all Rails 8 applications, though we’ll continue to support Sprockets for existing applications.
因此,我们感谢Sprockets 15年的服务,但Rails资产管道的未来称为Propshaft。现在,它是所有Rails 8应用程序的默认设置,尽管我们将继续为现有应用程序支持Sprockets。
Propshaft was created by David Heinemeier Hansson, from 37signals, and Breno Gazzola, from FestaLab.
authentication:
Generating the authentication basics.
生成身份验证基础。
Finally, making it easier to go to production also means we ought to make it easy to be secure. Rails has been assembling high-level abstractions for the key components of an excellent authentication system for a long time to bring that ease. We’ve had has_secure_password since Rails 5, but also recently introduced generates_token_for :password_reset along with authenticate_by in Rails 7.1. Now, with Rails 8, we’re putting all the pieces together in a complete authentication system generator, which creates an excellent starting point for a session-based, password-resettable, metadata-tracking authentication system.
最后,使生产更容易也意味着我们应该使安全更容易。长期以来,Rails一直在为一个优秀的身份验证系统的关键组件组装高级抽象,以简化这一过程。我们从Rails 5开始就有has_secure_password,但最近在Rails 7.1中引入了generates_token_for:password_reset和authenticate_by。现在,使用Rails 8,我们将所有部分整合到一个完整的身份验证系统生成器中,该生成器为基于会话、密码可重置、元数据跟踪的身份验证体系创建了一个很好的起点。
Just run bin/rails generate authentication and you’ll get basic models for Session and User, together with a PasswordsMailer, SessionsController, and an Authentication concern. All you have to bring yourself is a user sign-up flow (since those are usually bespoke to each application). No need to fear rolling your own authentication setup with these basics provided (or, heaven forbid, paying a vendor for it!).
只需运行bin/rails即可生成身份验证,您将获得会话和用户的基本模型,以及PasswordsMailer、SessionsController和身份验证问题。您只需为自己带来一个用户注册流程(因为这些流程通常是为每个应用程序定制的)。无需担心使用提供的这些基础知识来滚动自己的身份验证设置(或者,上帝保佑,不要为它付钱给供应商!)。
Nobuild:
The dream has come true. It’s now possible to build fast, modern web applications without transpiling or bundling either JavaScript or CSS. I’ve been working towards this personal nirvana ever since we begrudgingly started transpiling and bundling assets in the late 2000s. Browsers just weren’t good enough back then to avoid it. But they are now.
梦想成真了。现在可以构建快速、现代的web应用程序,而无需转换或绑定JavaScript或CSS。自从我们在21世纪末开始不情愿地运输和捆绑资产以来,我一直在努力实现个人涅盘。当时的浏览器还不够好,无法避免这种情况。但现在他们做到了。
I know you have to be a real nerd to think this is pretty, but I think this is pretty. Because I know what’s behind it. I know that looking at any of those individual files via View Source reveals exactly the same source code that I see in my editor. It’s been a long time since JavaScript developers and designers could say that. Now it’s possible.
我知道你必须是一个真正的书呆子才能认为这很漂亮,但我觉得这很漂亮。因为我知道它背后的原因。我知道通过查看源代码查看任何一个单独的文件都会显示出与我在编辑器中看到的完全相同的源代码。JavaScript开发人员和设计师已经很久没有这么说了。现在有可能了。