first commit

This commit is contained in:
2026-10-03 13:40:26 +02:00
parent 732a5b5a16
commit 566f415fa7
555 changed files with 62704 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import { Injectable, OnApplicationShutdown } from '@nestjs/common';
import Redis from 'ioredis';
/**
* Creates Redis connections and closes them on shutdown. Blocking commands
* (XREADGROUP BLOCK) and pub/sub subscribers need dedicated connections.
*/
@Injectable()
export class RedisConnectionFactory implements OnApplicationShutdown {
private readonly connections: Redis[] = [];
constructor(private readonly url: string) {}
create(name: string): Redis {
const connection = new Redis(this.url, {
connectionName: `task-stream:${name}`,
maxRetriesPerRequest: null,
});
this.connections.push(connection);
return connection;
}
async onApplicationShutdown(): Promise<void> {
await Promise.allSettled(this.connections.map((c) => c.quit()));
}
}

View File

@@ -0,0 +1,2 @@
export const REDIS_CLIENT = Symbol('REDIS_CLIENT');
export const GRAPHQL_PUB_SUB = Symbol('GRAPHQL_PUB_SUB');