rea-analysis-optimization
MOmorluto/rea486k8,943 new stars in the last 7 days
Apply best practices for Rails background jobs using simple orchestration, idempotency, and safe retries. Use when creating, refactoring, or debugging Active Job and queue-backed workflows.
Use for background job design and review. Patterns from Campfire (Resque, 4 thin jobs) and Fizzy (Solid Queue, multi-queue).
def perform(card) = card.notify_recipients.RecordNotUnique in the domain op).ActiveJob::Base.enqueue_after_transaction_commit = true in app defaults — fixes job-before-data races at the root.SOLID_QUEUE_IN_PUMA) in small deployments._later enqueues, plain name does the work, _now when you need an explicit synchronous twin:def notify_recipients # the work — public API the job calls
def notify_recipients_later # enqueues NotifyRecipientsJob (often private, called from callbacks)
Mention::CreateJob.perform_later(self, mentioner: Current.user)) — don't rely on Current at perform time.Current.account at enqueue (as a GlobalID) and wraps perform_now in Current.with_account.default, backend, webhooks) with explicit priority order in queue config.due.in_batches { |batch| ActiveJob.perform_all_later(batch.map { DeliverJob.new(it) }) }.ActiveJob::Continuable: step :dispatch + find_each(start: step.cursor) + step.advance! — essential for fan-out (webhooks, broadcasts, backfills).limits_concurrency to: 1, key: ->(owner) { owner } (Solid Queue).RejectedExecutionError for backpressure.after_destroy_commit async work, snapshot needed associations in before_destroy — the parent rows may be gone when the job runs.command: "MagicLink.cleanup"), not dedicated job classes.delete_all on scopes (stale.delete_all) — skip callbacks on stale rows.spend calls reset_if_due), not a scheduled job.retry_on ..., wait: :polynomially_longer (timeouts, DNS, Net::SMTPServerBusy).:info severity (it's expected — bad address, full mailbox), and move on. Keep job queue resources for work that can succeed.ActionMailer::MailDeliveryJob.include SmtpDeliveryErrorHandling).perform_enqueued_jobs(only: Mention::CreateJob) { ... } and assert_enqueued_with(job: ...).Current.user/Current.account inside perform without serializing it at enqueue.perform_later in a loop where perform_all_later or Continuable iteration fits.suppressing_turbo_broadcasts).MOmorluto/rea486k8,943 new stars in the last 7 days
Diagnose hard bugs and performance regressions by building a feedback loop with tests or scripts.
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days