今日已更新 35 条资讯 | 累计 37284 条内容
关于我们

标签:#sidekiq

找到 2 篇相关文章

AI 资讯

Ruby Reactor vs dry-transaction vs Trailblazer: Choosing a Ruby Workflow Library in 2026

Four ways to orchestrate business logic in Ruby. One map to find yours. You're building something that involves multiple steps. Charge a card, send an email, update inventory. Simple. Then someone says "What if step 3 fails? What undoes steps 1 and 2?" and suddenly you're evaluating workflow libraries. There are four mainstream approaches in Ruby today — Ruby Reactor , dry-transaction , Trailblazer , and raw Sidekiq jobs. This guide helps you pick the right one — not by ranking them, but by mapping them to the problem you're actually solving. The 30-Second Decision Matrix If you only have 30 seconds, start here: You want... Pick... A simple pipeline — 3-5 steps, top-to-bottom, no parallelism dry-transaction Railway-oriented programming with success/failure tracks, already in the Trailblazer ecosystem Trailblazer A full saga orchestrator — DAG dependency resolution, Sidekiq async, auto-compensation, locks, dashboard Ruby Reactor One-off fire-and-forget jobs, no coordination needed Raw Sidekiq None of these are "better" than the others. They solve different problems. Let's walk through each one. Meet the Libraries dry-transaction (v0.16.0) dry-transaction is a thin, focused gem from the dry-rb ecosystem. It wraps a series of operations in a sequential pipeline with a clean step DSL: class CreateUser < Dry :: Transaction step :validate step :persist step :send_welcome_email def validate ( input ) = # ... def persist ( input ) = # ... def send_welcome_email ( input ) = # ... end Steps run top-to-bottom. If any step returns a Failure , the pipeline stops immediately — no further steps execute. It's a railway under the hood: each step can produce Success(value) or Failure(error) , and the pipeline routes accordingly. What it's great at: Simple, synchronous pipelines. It's the Ruby equivalent of an Either monad chained with bind — clean, predictable, and minimal. If you're already in the dry-rb ecosystem (dry-validation, dry-types, dry-monads), it fits naturally. What it d

2026-07-26 原文 →
AI 资讯

Ruby Reactor Now Has Middlewares and OpenTelemetry — Here's Why That Matters

You've built a checkout reactor that reserves inventory, charges a card, generates a shipping label, and sends a confirmation email. It runs through Sidekiq. When something fails, compensation logic rolls it back. It works. Then your team asks: "How many checkouts failed this week? Which step? How long does the charge step take at p99? Can we see a trace through the entire system?" Before v0.5.0, you'd need to add logging calls to every step, build a custom Sidekiq middleware, and figure out how to correlate traces across async job boundaries. Now it's one line of config. Enter Middlewares Ruby Reactor 0.5.0 introduces a middleware pipeline — the same pattern that powers Rack, but designed for saga execution. A middleware is a plain Ruby object that hooks into the reactor lifecycle: class TimingMiddleware < RubyReactor :: Middleware def initialize ( ** options ) super @started = {} end def on_start_step ( step_name , _arguments , _context ) @started [ step_name ] = Process . clock_gettime ( Process :: CLOCK_MONOTONIC ) end def on_complete_step ( step_name , _result , _context ) started = @started . delete ( step_name ) return unless started elapsed = Process . clock_gettime ( Process :: CLOCK_MONOTONIC ) - started logger . info ( "step #{ step_name } took #{ elapsed . round ( 4 ) } s" ) end end This middleware times every step. Register it globally: RubyReactor . configure do | config | config . middlewares = [ TimingMiddleware ] end Now every reactor — every checkout, every refund, every data import — gets step-level timing, for free. The full lifecycle (20+ events) Middlewares can observe the complete execution lifecycle: Phase Events Reactor on_start_reactor , on_complete_reactor , on_failed_reactor Step on_start_step , on_complete_step , on_failed_step , on_retry_attempt Compensation on_start_compensation , on_complete_compensation , on_failed_compensation Undo on_start_undo , on_complete_undo , on_failed_undo Coordination on_lock_acquired , on_lock_failed , on_

2026-06-17 原文 →