b38405cb88
* Add createdAt filter to realtime subscribing with tags * Filter realtime colums and expose ability to skip some columns * Add sharding support for electric * Use unkey cache for the created at filter caching * Remove 2 unused indexes on TaskRun * Run list now filters by a single runtime environment * Remove project ID indexes * Use clickhouse in task list aggregation queries instead of pg (keep pg for self-hosters) * WIP clickhouse powered runs list stuff * Improve the query to get the latest tasks for the task list presenter * Update the usage task list to use clickhouse * Implement next runs list powered by clickhouse * Add new index for TaskRun for the runs list, by environment ID * Add runTags gin index * Handle possibly malicious inputs * Ignore claude settings * Better handling not finding an environment on the schedule page * Use ms since epoch in test, not seconds * Remove unused function * Fix test * Use an env var for the realtime maximum createdAt filter duration (defaults to 1 day) * Fixed the query builder to correct the group by / order by order * Make sure runs.list still works * Create small-birds-arrive.md
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { env } from "~/env.server";
|
|
import { singleton } from "~/utils/singleton";
|
|
import { RealtimeClient } from "./realtimeClient.server";
|
|
import { getCachedLimit } from "./platform.v3.server";
|
|
|
|
function initializeRealtimeClient() {
|
|
const electricOrigin = env.ELECTRIC_ORIGIN_SHARDS?.split(",") ?? env.ELECTRIC_ORIGIN;
|
|
|
|
return new RealtimeClient({
|
|
electricOrigin: electricOrigin,
|
|
keyPrefix: "tr:realtime:concurrency",
|
|
redis: {
|
|
port: env.RATE_LIMIT_REDIS_PORT,
|
|
host: env.RATE_LIMIT_REDIS_HOST,
|
|
username: env.RATE_LIMIT_REDIS_USERNAME,
|
|
password: env.RATE_LIMIT_REDIS_PASSWORD,
|
|
tlsDisabled: env.RATE_LIMIT_REDIS_TLS_DISABLED === "true",
|
|
clusterMode: env.RATE_LIMIT_REDIS_CLUSTER_MODE_ENABLED === "1",
|
|
},
|
|
cachedLimitProvider: {
|
|
async getCachedLimit(organizationId, defaultValue) {
|
|
const result = await getCachedLimit(
|
|
organizationId,
|
|
"realtimeConcurrentConnections",
|
|
defaultValue
|
|
);
|
|
|
|
return result.val;
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export const realtimeClient = singleton("realtimeClient", initializeRealtimeClient);
|