export interface RetryOptions {
retries: number;
baseMs: number;
maxMs: number;
signal?: AbortSignal;
onRetry?: (attempt: number, delay: number, err: unknown) => void;
package dbutil
import (
"context"
"github.com/jackc/pgconn"
class CreateDeadJobs < ActiveRecord::Migration[7.1]
def change
create_table :dead_jobs do |t|
t.string :jid, null: false
t.string :queue, null: false
t.string :klass, null: false
type AsyncTask = () => Promise<void>;
export interface GuardOptions {
name: string;
logger?: Pick<Console, "info" | "warn" | "error">;
}
require "timeout"
module HealthCheck
class Probe
Result = Struct.new(:name, :status, :latency_ms, :critical, :error, keyword_init: true) do
def healthy?
class FeatureFlag < ApplicationRecord
validates :key, presence: true, uniqueness: true
validates :percentage, inclusion: { in: 0..100 }
after_commit :expire_cache
CREATE TABLE outbox (
id BIGSERIAL PRIMARY KEY,
aggregate_type TEXT NOT NULL,
aggregate_id TEXT NOT NULL,
event_type TEXT NOT NULL,
payload JSONB NOT NULL,
class CreateProcessedEvents < ActiveRecord::Migration[7.1]
def change
create_table :processed_events do |t|
t.string :event_key, null: false
t.string :job_class, null: false
t.jsonb :metadata, null: false, default: {}
class ReindexCheckpoint < ApplicationRecord
enum status: { idle: 0, running: 1, done: 2, failed: 3 }
validates :index_name, presence: true, uniqueness: true
def self.for(index_name)
import { Pool, PoolClient, Client, QueryResult, QueryResultRow } from 'pg';
const MAX_LIFETIME_MS = 30 * 60 * 1000;
export const pool = new Pool({
connectionString: process.env.DATABASE_URL,
module Middleware
class DatabasePinning
PIN_WINDOW = 5.seconds
def initialize(app)
@app = app
package config
import (
"errors"
"os"
"strconv"