forked from liaoliaots/nestjs-redis
-
Notifications
You must be signed in to change notification settings - Fork 3
/
redis-module-options.interface.ts
98 lines (87 loc) · 2.42 KB
/
redis-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
93
94
95
96
97
98
import { Type, ModuleMetadata, Provider } from '@nestjs/common';
import { Redis, RedisOptions } from 'ioredis';
import { ClientNamespace } from '@/interfaces';
/**
* @public
*/
export interface RedisClientOptions extends RedisOptions {
/**
* Client name. If client name is not given then it will be called "default".
* Different clients must have different names.
*
* @defaultValue `"default"`
*/
namespace?: ClientNamespace;
/**
* URI scheme to be used to specify connection options as a redis:// URL or rediss:// URL.
*
* - redis - https://www.iana.org/assignments/uri-schemes/prov/redis
* - rediss - https://www.iana.org/assignments/uri-schemes/prov/rediss
*
* @example
* ```ts
* // Connect to 127.0.0.1:6380, db 4, using password "authpassword":
* 'redis://:authpassword@127.0.0.1:6380/4'
* ```
*/
url?: string;
/**
* Path to be used for Unix domain sockets.
*/
path?: string;
/**
* Function to be executed as soon as the client is created.
*
* @param client - The new client created
*/
onClientCreated?: (client: Redis) => void;
}
/**
* @public
*/
export interface RedisModuleOptions {
/**
* If set to `true`, all clients will be closed automatically on nestjs application shutdown.
*
* @defaultValue `true`
*/
closeClient?: boolean;
/**
* Common options to be passed to each client.
*/
commonOptions?: RedisOptions;
/**
* 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?: RedisClientOptions | RedisClientOptions[];
}
/**
* @public
*/
export interface RedisModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
useFactory?: (...args: any[]) => RedisModuleOptions | Promise<RedisModuleOptions>;
useClass?: Type<RedisOptionsFactory>;
useExisting?: Type<RedisOptionsFactory>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
inject?: any[];
extraProviders?: Provider[];
}
/**
* @public
*/
export interface RedisOptionsFactory {
createRedisOptions: () => RedisModuleOptions | Promise<RedisModuleOptions>;
}