import uuid
from django.db import models
class Cart(models.Model):
OPEN = "open"
class TokenBucket {
constructor(capacity, refillPerSecond) {
this.capacity = capacity;
this.refillPerMs = refillPerSecond / 1000;
this.tokens = capacity;
this.lastRefill = Date.now();
package worker
import (
"context"
"errors"
"log"
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,
import asyncio
import time
from dataclasses import dataclass
from typing import Any, Dict
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::Mutex;
use tokio::time::sleep;
#[derive(Debug)]
<?php
namespace App\Http\Controllers;
use App\Models\Wallet;
use App\Services\WalletService;
package pipeline
import "context"
func generate(ctx context.Context, nums ...int) <-chan int {
out := make(chan int)
class CounterFlushJob
include Sidekiq::Job
sidekiq_options queue: :counters, retry: 3
def perform
CounterBuffer.flush_all.each do |field, delta|
import { Queue } from "bullmq";
import { createHash } from "crypto";
export const connection = { host: "127.0.0.1", port: 6379 };
export interface ChargePayload {
class DiscountCode < ApplicationRecord
has_many :redemptions, dependent: :destroy
enum discount_type: { percentage: 0, fixed: 1 }
validates :code, presence: true, uniqueness: { case_sensitive: false }
import time
import uuid
from dataclasses import dataclass
import redis