use std::time::Duration;
use tokio_util::sync::CancellationToken;
pub struct Worker {
id: usize,
token: CancellationToken,
@Configuration
@EnableAsync
public class AsyncConfig {
@Bean(name = "orderExecutor")
public ThreadPoolTaskExecutor orderExecutor() {
CREATE TYPE outbox_status AS ENUM ('pending', 'retry', 'processing', 'done', 'dead');
CREATE TABLE outbox_events (
id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
dedupe_key TEXT NOT NULL,
topic TEXT NOT NULL,
package main
import (
"context"
"log"
"net/http"
class AddSlugToPosts < ActiveRecord::Migration[7.1]
def change
add_column :posts, :slug, :string, null: false
add_index :posts, :slug, unique: true
end
end
from django.db import transaction
from django.shortcuts import get_object_or_404
from django.http import JsonResponse
from .models import Product
-- KEYS[1] = bucket key
-- ARGV[1] = capacity, ARGV[2] = refill_per_sec, ARGV[3] = now (float seconds)
local capacity = tonumber(ARGV[1])
local rate = tonumber(ARGV[2])
local now = tonumber(ARGV[3])
require "securerandom"
class RedisMutex
class LockError < StandardError; end
UNLOCK_SCRIPT = <<~LUA.freeze
package pricecache
import (
"context"
"sync"
class PresenceRegistry
TTL = 30 # seconds a user counts as present without a heartbeat
def initialize(room_id, redis: REDIS)
@room_id = room_id
@redis = redis
<?php
namespace App\Jobs;
use App\Models\Invoice;
use App\Services\StripeGateway;
class AddLockVersionToPosts < ActiveRecord::Migration[6.1]
def change
add_column :posts, :lock_version, :integer, default: 0, null: false
end
end