module ConnectionHealth
extend ActiveSupport::Concern
def with_fresh_connection
conn = ActiveRecord::Base.connection
conn.verify! # pings and reconnects if the socket is dead
public final class Debouncer implements AutoCloseable {
private final ScheduledExecutorService scheduler;
private final long delayMillis;
private final AtomicReference<ScheduledFuture<?>> pending = new AtomicReference<>();
use std::sync::{Arc, Mutex};
use std::thread;
fn main() {
let counter = Arc::new(Mutex::new(0));
let mut handles = vec![];
class Current < ActiveSupport::CurrentAttributes
attribute :tenant, :request_id
def tenant=(tenant)
super
Rails.logger.tagged("tenant=#{tenant&.id}") if tenant
import com.github.benmanes.caffeine.cache.CacheLoader;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
module BoundedFanOut
Result = Struct.new(:value, :error) do
def ok?
error.nil?
end
end
import errno
import fcntl
import os
import time
import functools
import threading
def debounce(wait):
def decorator(func):
use std::collections::HashMap;
use std::sync::{Arc, Mutex, PoisonError};
#[derive(Default)]
struct Metrics {
per_endpoint: HashMap<String, u64>,
import { Pool } from "pg";
async function keyFor(pool: Pool, name: string): Promise<string> {
const { rows } = await pool.query<{ key: string }>(
"SELECT hashtextextended($1, 0) AS key",
[name]
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() {
let handle = tokio::spawn(async {
sleep(Duration::from_millis(100)).await;
class Order < ApplicationRecord
include TransactionalEnqueue
belongs_to :customer
has_many :line_items, dependent: :destroy