class AddOptimisticLockingToDocuments < ActiveRecord::Migration[7.1]
def change
add_column :documents, :lock_version, :integer, null: false, default: 0
add_index :documents, :updated_at
end
end
package consumers
import (
"context"
"github.com/jackc/pgx/v5/pgxpool"
package main
import (
"time"
"google.golang.org/grpc"
package ingest
import (
"bufio"
"bytes"
"io"
module RetryableTransaction
module_function
RETRIABLE = [ActiveRecord::Deadlocked, ActiveRecord::LockWaitTimeout].freeze
def run(max_retries: 3, base_delay: 0.05, &block)
module Idempotency
extend ActiveSupport::Concern
included do
before_action :check_idempotency_key, only: [:create, :update]
after_action :store_idempotent_response, only: [:create, :update]
class CreateEmailDeliveries < ActiveRecord::Migration[7.1]
def change
create_table :email_deliveries do |t|
t.string :dedupe_key, null: false
t.string :mailer, null: false
t.string :action, null: false
require "faraday"
require "faraday/retry"
module Http
class RetryableError < StandardError; end
class CircuitOpenError < StandardError; end
package deps
import (
"context"
"net/http"
"time"
package cache
import (
"context"
"sync/atomic"
"time"
class NotifyFollowersJob
include Sidekiq::Job
sidekiq_options queue: :notifications, retry: 5
def perform(post_id, actor_id)
package cache
import (
"context"
"sync"
"time"