Code Explainers

Code explainers tagged #background-jobs

ruby
class Api::MessagesController < ApiController
  before_action :authenticate_api_key!
 
  rate_limit to: 100,

Layered API rate limiting in Rails

rate-limiting api-authentication throttling
Intermediate 9 steps
php
<?php
 
namespace App\Jobs;
 

A retrying queue job in Laravel

queues background-jobs retries
Intermediate 7 steps
ruby
class SyncContactsJob < ApplicationJob
  queue_as :external_api
 
  MAX_CONCURRENCY = 5

Rate-limited CRM sync in a Rails job

background-jobs rate-limiting redis
Advanced 9 steps
ruby
class DatasetImportJob < ApplicationJob
  queue_as :default
 
  def perform(import)

Streaming import progress with a Rails job

background-jobs turbo-streams progress-tracking
Intermediate 9 steps
ruby
class OrdersController < ApplicationController
  rescue_from ActiveRecord::RecordNotUnique, with: :handle_duplicate_submission
 
  def create

Idempotent order creation in Rails

idempotency database-constraints error-handling
Intermediate 8 steps
php
<?php
 
namespace App\Jobs;
 

Building a unique queued job in Laravel

queues background-jobs idempotency
Intermediate 7 steps
rust
use std::sync::Arc;
 
use axum::{
    extract::State,

Offloading work with a channel in Axum

background-jobs message-passing shared-state
Intermediate 9 steps
ruby
class SearchIndexReconciler
  DEBOUNCE_WINDOW = 5.seconds
 
  def self.schedule(record)

Debouncing search reindex jobs in Rails

debouncing background-jobs caching
Advanced 7 steps
ruby
class PurgeStaleExportsJob < ApplicationJob
  queue_as :maintenance
 
  retry_on ActiveRecord::Deadlocked, wait: :polynomially_longer, attempts: 5

Purging stale exports with an Active Job in Rails

background-jobs batching error-handling
Intermediate 7 steps
typescript
import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository, LessThan } from 'typeorm';

Scheduled session cleanup in NestJS

cron-scheduling background-jobs repository-pattern
Intermediate 7 steps
ruby
class ReportBatcher
  BATCH_SIZE = 500
 
  def initialize(account)

Batching monthly email summaries in Rails

batching service-object background-jobs
Intermediate 7 steps
ruby
class OrderConfirmationJob < ApplicationJob
  queue_as :mailers
 
  retry_on Net::OpenTimeout, wait: :polynomially_longer, attempts: 5

Resilient background jobs in Rails

background-jobs retries idempotency
Intermediate 8 steps
php
<?php
 
namespace App\Console;
 

How task scheduling works in Laravel

scheduling cron fluent-api
Intermediate 7 steps
rust
use axum::{
    extract::State,
    http::StatusCode,
    response::IntoResponse,

An async job queue handler in Axum

background-jobs async http-202
Intermediate 9 steps