Rails 8.1의 주요 개선 사항
1. Active Job 연속성 (Active Job Continuations)
장기 실행 작업을 개별 단계로 분할하여 재시작 시 마지막 완료된 단계부터 실행을 재개할 수 있습니다. 이는 Kamal을 사용한 배포 시 작업 컨테이너 종료 시간을 효과적으로 관리할 수 있도록 돕습니다.
ruby
class ProcessImportJob < ApplicationJob
include ActiveJob::Continuable
def perform(import_id)
@import = Import.find(import_id)
step :initialize do
@import.initialize
end
step :process do |step|
@import.records.find_each(start: step.cursor) do |record|
record.process
step.advance! from: record.id
end
end
step :finalize
end
private
def finalize
@import.finalize
end
end
2. 구조화된 이벤트 보고 (Structured Event Reporting)
Rails 애플리케이션 내에서 구조화된 이벤트를 생성하기 위한 통일된 인터페이스를 제공합니다. 기존 로거보다 후처리(post-processing)에 적합하며, 태그 및 컨텍스트 추가를 지원합니다.
ruby
Rails.event.notify("user.signup", user_id: 123, email: "user@example.com")
Rails.event.tagged("graphql") do
Rails.event.notify("user.signup", user_id: 123, email: "user@example.com")
end
Rails.event.set_context(request_id: "abc123", shop_id: 456)
3. 로컬 CI (Local CI)
개발 머신에서 빠르고 효율적으로 테스트 스위트를 실행할 수 있는 기본 CI 선언 DSL이 추가되었습니다. config/ci.rb에 정의되며 bin/ci로 실행됩니다. 이는 클라우드 CI 의존도를 줄이고 개발 워크플로우를 가속화합니다.
ruby
CI.run do
step "Setup", "bin/setup --skip-server"
step "Style: Ruby", "bin/rubocop"
step "Security: Gem audit", "bin/bundler-audit"
step "Tests: Rails", "bin/rails test"
if success?
step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
else
failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
end
end
4. 기타 주요 기능
-
Markdown 렌더링:
render markdown: @object를 통해 마크다운 응답을 쉽게 처리할 수 있습니다. -
명령줄 자격 증명 가져오기: Kamal이 Rails 암호화된 자격 증명 저장소에서 비밀을 가져올 수 있습니다.
-
사용 중단된 연관 관계: Active Record 연관 관계를
deprecated: true로 표시하여 사용 보고를 활성화할 수 있습니다. -
레지스트리 없는 Kamal 배포: Kamal 2.8부터 기본적으로 로컬 레지스트리를 사용하여 간단한 배포를 지원합니다.