style(biome): using biome for format, lint, check
This commit is contained in:
+13
-13
@@ -5,11 +5,11 @@ import * as schema from "@/schema";
|
||||
const isDevelopment = process.env.NODE_ENV === "development";
|
||||
|
||||
const connectionConfig = {
|
||||
max: isDevelopment ? 8 : 12,
|
||||
idleTimeoutMillis: isDevelopment ? 5_000 : 60_000,
|
||||
connectionTimeoutMillis: 15_000,
|
||||
maxUses: isDevelopment ? 100 : 0,
|
||||
allowExitOnIdle: true,
|
||||
connectionTimeoutMillis: 15_000,
|
||||
idleTimeoutMillis: isDevelopment ? 5_000 : 60_000,
|
||||
max: isDevelopment ? 8 : 12,
|
||||
maxUses: isDevelopment ? 100 : 0,
|
||||
};
|
||||
|
||||
const pool = new Pool({
|
||||
@@ -20,12 +20,12 @@ const pool = new Pool({
|
||||
// Lightweight connection pool monitoring (single pool)
|
||||
export const getConnectionPoolStats = () => {
|
||||
const stats = {
|
||||
active: Math.max(0, (pool.totalCount ?? 0) - (pool.idleCount ?? 0)),
|
||||
ended: (pool as any).ended ?? false,
|
||||
idle: pool.idleCount ?? 0,
|
||||
name: "primary",
|
||||
total: pool.options.max ?? 0,
|
||||
idle: pool.idleCount ?? 0,
|
||||
active: Math.max(0, (pool.totalCount ?? 0) - (pool.idleCount ?? 0)),
|
||||
waiting: pool.waitingCount ?? 0,
|
||||
ended: (pool as any).ended ?? false,
|
||||
};
|
||||
|
||||
const totalConnections = connectionConfig.max;
|
||||
@@ -33,23 +33,23 @@ export const getConnectionPoolStats = () => {
|
||||
totalConnections > 0 ? Math.round((stats.active / totalConnections) * 100) : 0;
|
||||
|
||||
return {
|
||||
timestamp: new Date().toISOString(),
|
||||
region: process.env.FLY_REGION || "unknown",
|
||||
instance: process.env.FLY_ALLOC_ID || "local",
|
||||
pools: { primary: stats },
|
||||
region: process.env.FLY_REGION || "unknown",
|
||||
summary: {
|
||||
totalConnections,
|
||||
totalActive: stats.active,
|
||||
totalWaiting: stats.waiting,
|
||||
hasExhaustedPools: stats.active >= totalConnections || (stats.waiting ?? 0) > 0,
|
||||
totalActive: stats.active,
|
||||
totalConnections,
|
||||
totalWaiting: stats.waiting,
|
||||
utilizationPercent: utilization,
|
||||
},
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
};
|
||||
|
||||
export const db = drizzle(pool, {
|
||||
schema,
|
||||
casing: "snake_case",
|
||||
schema,
|
||||
});
|
||||
export const connectDb = async () => db;
|
||||
export type Database = Awaited<ReturnType<typeof connectDb>>;
|
||||
|
||||
Reference in New Issue
Block a user