reliability

ruby
class CreateOutboxEvents < ActiveRecord::Migration[7.1]
  def change
    create_table :outbox_events do |t|
      t.string :event_type, null: false
      t.string :aggregate_type, null: false
      t.string :aggregate_id, null: false

Transactional Outbox for Reliable Event Publishing

rails background-jobs reliability
by codesnips 4 tabs
javascript
const express = require('express');
const webhookRouter = require('./webhookRouter');
const apiRouter = require('./apiRouter');

const app = express();

Verify Stripe Webhook Signatures with a Raw-Body Express Route

express stripe webhooks
by codesnips 3 tabs
go
package httpretry

import (
	"math/rand"
	"time"
)

Exponential Backoff With Full Jitter for Flaky HTTP Calls in Go

go http retry
by codesnips 3 tabs
go
package retry

import (
  "context"
  "math/rand"
  "time"

Exponential backoff with jitter for retries

go reliability retry
by Leah Thompson 1 tab
ruby
class DeliveryObserver
  def self.delivered_email(message)
    new(message).record
  end

  def initialize(message)

Action Mailer Delivery Observability Hook

rails observability action-mailer
by codesnips 3 tabs
go
package config

import (
  "io"

  "gopkg.in/yaml.v3"

Safe YAML decoding (KnownFields) for config files

go config yaml
by Leah Thompson 1 tab
python
from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver

from .models import EmailOutbox

Sending Welcome Emails via a Django post_save Signal and Outbox Worker

django signals email
by codesnips 4 tabs
rust
use std::time::Duration;
use rand::Rng;

#[derive(Clone, Debug)]
pub struct BackoffPolicy {
    pub base_delay: Duration,

Exponential Backoff With Jitter for Retrying Fallible Async Operations in Rust

rust tokio async
by codesnips 3 tabs
ruby
class WebhookSignature
  class VerificationError < StandardError; end

  TOLERANCE = 300 # seconds

  def initialize(payload:, header:, secrets:)

Robust Webhook Verification (HMAC + Timestamp)

rails security webhooks
by codesnips 3 tabs
go
package ratelimit

import (
	"sync"
	"time"
)

Token Bucket Rate-Limiting Middleware for a Go net/http API

go net-http middleware
by codesnips 4 tabs
rust
use std::time::Duration;
use tokio_util::sync::CancellationToken;

pub struct Worker {
    id: usize,
    token: CancellationToken,

Graceful Task Shutdown in Tokio Using CancellationToken

tokio async cancellation
by codesnips 3 tabs
java
@Configuration
@EnableAsync
public class AsyncConfig {

    @Bean(name = "orderExecutor")
    public ThreadPoolTaskExecutor orderExecutor() {

Debouncing Order Recalculations with Spring @Async and a Configured ThreadPoolTaskExecutor

spring-boot async thread-pool
by codesnips 3 tabs