forked from liaoliaots/nestjs-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster-module-options.interface.ts
92 lines (83 loc) · 2.19 KB
/
cluster-module-options.interface.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { Type, ModuleMetadata, Provider } from '@nestjs/common';
import type { Cluster } from 'ioredis';
import { ClusterNode, ClusterOptions } from 'ioredis';
import { ClientNamespace } from '@/interfaces';
/**
* @public
*/
export interface ClusterClientOptions extends ClusterOptions {
/**
* Client name. If client name is not given then it will be called "default".
* Different clients must have different names.
*
* @defaultValue `"default"`
*/
namespace?: ClientNamespace;
/**
* List of cluster nodes.
*
* @example
* ```ts
* // Connect with url
* ['redis://:[email protected]:16380']
* ```
*
* @example
* ```ts
* // Connect with host, port
* [{ host: '127.0.0.1', port: 16380 }]
* ```
*/
nodes: ClusterNode[];
/**
* Function to be executed as soon as the client is created.
*
* @param client - The new client created
*/
onClientCreated?: (client: Cluster) => void;
}
/**
* @public
*/
export interface ClusterModuleOptions {
/**
* If set to `true`, all clients will be closed automatically on nestjs application shutdown.
*
* @defaultValue `true`
*/
closeClient?: boolean;
/**
* If set to `true`, then ready logging will be displayed when the client is ready.
*
* @defaultValue `false`
*/
readyLog?: boolean;
/**
* If set to `true`, then errors that occurred while connecting will be displayed by the built-in logger.
*
* @defaultValue `true`
*/
errorLog?: boolean;
/**
* Used to specify single or multiple clients.
*/
config: ClusterClientOptions | ClusterClientOptions[];
}
/**
* @public
*/
export interface ClusterModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
useFactory?: (...args: any[]) => ClusterModuleOptions | Promise<ClusterModuleOptions>;
useClass?: Type<ClusterOptionsFactory>;
useExisting?: Type<ClusterOptionsFactory>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
inject?: any[];
extraProviders?: Provider[];
}
/**
* @public
*/
export interface ClusterOptionsFactory {
createClusterOptions: () => ClusterModuleOptions | Promise<ClusterModuleOptions>;
}