Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(core): Simplify Redis client types (no-changelog) #10397

Merged
merged 4 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Suffix with -Type
  • Loading branch information
ivov committed Aug 15, 2024
commit 66e48e99d5b47b6809f91b519ccbebb72d56c03d
6 changes: 3 additions & 3 deletions packages/cli/src/services/redis/RedisServiceBaseClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Service } from 'typedi';
import config from '@/config';
import { Logger } from '@/Logger';
import { RedisClientService } from './redis-client.service';
import type { RedisClient } from './redis.types';
import type { RedisClientType } from './redis.types';

export type RedisServiceMessageHandler =
| ((channel: string, message: string) => void)
Expand All @@ -21,7 +21,7 @@ class RedisServiceBase {
private readonly redisClientService: RedisClientService,
) {}

async init(type: RedisClient): Promise<void> {
async init(type: RedisClientType): Promise<void> {
if (this.redisClient && this.isInitialized) {
return;
}
Expand Down Expand Up @@ -49,7 +49,7 @@ class RedisServiceBase {
export abstract class RedisServiceBaseSender extends RedisServiceBase {
senderId: string;

async init(type: RedisClient): Promise<void> {
async init(type: RedisClientType): Promise<void> {
await super.init(type);
this.senderId = config.get('redis.queueModeId');
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/services/redis/redis-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Service } from 'typedi';
import { Logger } from '@/Logger';
import ioRedis from 'ioredis';
import type { Cluster, RedisOptions } from 'ioredis';
import type { RedisClient } from './redis.types';
import type { RedisClientType } from './redis.types';

import { OnShutdown } from '@/decorators/OnShutdown';
import { LOWEST_SHUTDOWN_PRIORITY } from '@/constants';
Expand All @@ -17,7 +17,7 @@ export class RedisClientService {
private readonly globalConfig: GlobalConfig,
) {}

createClient(arg: { type: RedisClient; extraOptions?: RedisOptions }) {
createClient(arg: { type: RedisClientType; extraOptions?: RedisOptions }) {
const client =
this.clusterNodes().length > 0
? this.createClusterClient(arg)
Expand Down Expand Up @@ -56,7 +56,7 @@ export class RedisClientService {
type,
extraOptions,
}: {
type: RedisClient;
type: RedisClientType;
extraOptions?: RedisOptions;
}) {
const options = this.getOptions({ extraOptions });
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/services/redis/redis.types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type RedisClient = n8nRedisClient | BullRedisClient;
export type RedisClientType = n8nRedisClientType | BullRedisClientType;

/**
* Redis client used by n8n.
Expand All @@ -7,7 +7,7 @@ export type RedisClient = n8nRedisClient | BullRedisClient;
* - `publisher(n8n)` to send messages into scaling mode communication channels
* - `cache(n8n)` for caching operations (variables, resource ownership, etc.)
*/
type n8nRedisClient = 'subscriber(n8n)' | 'publisher(n8n)' | 'cache(n8n)';
type n8nRedisClientType = 'subscriber(n8n)' | 'publisher(n8n)' | 'cache(n8n)';

/**
* Redis client used internally by Bull. Suffixed with `(bull)` at `ScalingService.setupQueue`.
Expand All @@ -16,4 +16,4 @@ type n8nRedisClient = 'subscriber(n8n)' | 'publisher(n8n)' | 'cache(n8n)';
* - `client(bull)` for general queue operations
* - `bclient(bull)` for blocking operations when processing jobs
*/
type BullRedisClient = 'subscriber(bull)' | 'client(bull)' | 'bclient(bull)';
type BullRedisClientType = 'subscriber(bull)' | 'client(bull)' | 'bclient(bull)';