import time
import threading
from collections import deque, defaultdict
class SlidingWindowLimiter:
require "sidekiq/api"
class QueueDepthGuard
class QueueSaturated < StandardError
attr_reader :queue, :depth
package com.shop.inventory;
import jakarta.persistence.*;
@Entity
@Table(name = "inventory_item")
# Basic Ractor usage
ractor = Ractor.new do
# This runs in parallel, isolated from main thread
result = heavy_computation
result
end
package com.example.orders;
public final class Order {
public static final Order POISON_PILL = new Order(-1L, 0.0);
package main
import (
"context"
"log"
"net/http"
-- KEYS[1] = current window key, KEYS[2] = previous window key
-- ARGV: limit, window_ms, elapsed_ms
local limit = tonumber(ARGV[1])
local window = tonumber(ARGV[2])
local elapsed = tonumber(ARGV[3])
package service
import (
"context"
"golang.org/x/sync/errgroup"
import asyncio
import time
from dataclasses import dataclass, field
@dataclass
use std::os::raw::c_int;
pub const LOCK_EX: c_int = 2;
pub const LOCK_NB: c_int = 4;
pub const LOCK_UN: c_int = 8;
class TokenBucket {
constructor(capacity, refillPerSecond) {
this.capacity = capacity;
this.refillPerMs = refillPerSecond / 1000;
this.tokens = capacity;
this.lastRefill = Date.now();
CREATE TABLE daily_metrics (
id BIGGENERATED ALWAYS AS IDENTITY PRIMARY KEY,
tenant_id BIGINT NOT NULL,
metric TEXT NOT NULL,
day DATE NOT NULL,
count BIGINT NOT NULL DEFAULT 0,