@Configuration
public class TxConfig {
@Bean
public PlatformTransactionManager transactionManager(DataSource dataSource) {
DataSourceTransactionManager tm = new DataSourceTransactionManager(dataSource);
class DebouncedReindexJob
include Sidekiq::Job
sidekiq_options queue: :indexing, retry: 5
DEBOUNCE_DELAY = 5 # seconds
package httpcache
import (
"strconv"
"strings"
"time"
use dashmap::DashMap;
use std::time::Instant;
pub struct TokenBucket {
tokens: f64,
last_refill: Instant,
class BatchLoader {
constructor(batchFn, { cacheKeyFn = (k) => k } = {}) {
this.batchFn = batchFn;
this.cacheKeyFn = cacheKeyFn;
this.cache = new Map();
this.queue = [];
package mailer
import (
"crypto/sha256"
"encoding/hex"
"strings"
use tokio::sync::broadcast;
pub struct Shutdown {
is_shutdown: bool,
notify: broadcast::Receiver<()>,
}
class InventoryLevel < ApplicationRecord
belongs_to :warehouse
UPSERT_COLUMNS = %w[warehouse_id sku on_hand reserved updated_at].freeze
def self.upsert_counts(rows)
class Order < ApplicationRecord
class InvalidTransition < StandardError; end
enum status: { pending: 0, paid: 1, shipped: 2, cancelled: 3 }
has_many :order_transitions, -> { order(:created_at) }, dependent: :destroy
package health
import (
"context"
"sync"
"time"
from collections import defaultdict
from dataclasses import dataclass, field
from typing import Callable, Dict, List, Set
class CycleError(Exception):
use notify::{Event, RecommendedWatcher, RecursiveMode, Watcher};
use std::path::{Path, PathBuf};
use std::sync::mpsc;
pub fn spawn_watcher(root: &Path) -> notify::Result<(RecommendedWatcher, flume::Receiver<PathBuf>)> {
let (raw_tx, raw_rx) = mpsc::channel::<notify::Result<Event>>();