from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver
from .models import EmailOutbox
class WebhookSignature
class VerificationError < StandardError; end
TOLERANCE = 300 # seconds
def initialize(payload:, header:, secrets:)
use std::time::Duration;
use rand::Rng;
#[derive(Clone, Debug)]
pub struct BackoffPolicy {
pub base_delay: Duration,
package ratelimit
import (
"sync"
"time"
)
-- KEYS[1] = bucket key
-- ARGV: capacity, refillPerSec, now(ms), cost, ttl(sec)
local capacity = tonumber(ARGV[1])
local refill = tonumber(ARGV[2])
local now = tonumber(ARGV[3])
local cost = tonumber(ARGV[4])
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,
import random
from dataclasses import dataclass
from typing import Iterator
@dataclass(frozen=True)
<?php
namespace App\Entity;
trait RecordsEvents
{
package com.shop.orders.events;
import java.math.BigDecimal;
import java.time.Instant;
public record OrderPlacedEvent(
package config
import (
"fmt"
"os"
"strconv"