package httpstream
import (
"bufio"
"database/sql"
"fmt"
CREATE TABLE idempotency_keys (
id BIGSERIAL PRIMARY KEY,
idempotency_key TEXT NOT NULL,
request_path TEXT NOT NULL,
request_fingerprint TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'in_progress',
import base64
import json
from datetime import datetime
from typing import Optional, Tuple
import uuid
from django.db import models
class Cart(models.Model):
OPEN = "open"
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,
module StatementTimeout
extend ActiveSupport::Concern
class TimeoutExceeded < StandardError; end
def with_statement_timeout(milliseconds)
from sqlalchemy import select
from .models import Order, db
def stream_orders(batch_size=1000):
package com.example.feed;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.Base64;
class CounterFlushJob
include Sidekiq::Job
sidekiq_options queue: :counters, retry: 3
def perform
CounterBuffer.flush_all.each do |field, delta|
class DiscountCode < ApplicationRecord
has_many :redemptions, dependent: :destroy
enum discount_type: { percentage: 0, fixed: 1 }
validates :code, presence: true, uniqueness: { case_sensitive: false }
const { AsyncLocalStorage } = require('async_hooks');
const storage = new AsyncLocalStorage();
function runWithTenant(tenantId, userId, callback) {
return storage.run({ tenantId, userId }, callback);
import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
export async function getFeedNaive(limit = 20) {
const posts = await prisma.post.findMany({