-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add redis-clusters to docker and adjust tests
- Loading branch information
Showing
6 changed files
with
169 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ThrottlerModule } from '@nestjs/throttler'; | ||
import { ThrottlerStorageRedisClusterService } from '../../../src/throttler-storage-redis-cluster.service'; | ||
import { clusterNodes } from '../../utility/redis'; | ||
import { AppService } from '../app.service'; | ||
import { AppController } from './app.controller'; | ||
import { DefaultController } from './default.controller'; | ||
import { LimitController } from './limit.controller'; | ||
|
||
@Module({ | ||
imports: [ | ||
ThrottlerModule.forRoot({ | ||
limit: 5, | ||
ttl: 60, | ||
ignoreUserAgents: [/throttler-test/g], | ||
storage: new ThrottlerStorageRedisClusterService(clusterNodes), | ||
}), | ||
], | ||
controllers: [AppController, DefaultController, LimitController], | ||
providers: [AppService], | ||
}) | ||
export class ClusterControllerModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import Redis from 'ioredis'; | ||
import Redis, { Cluster } from 'ioredis'; | ||
|
||
export const clusterNodes = [ | ||
{ host: '127.0.0.1', port: 7000 }, | ||
{ host: '127.0.0.1', port: 7001 }, | ||
{ host: '127.0.0.1', port: 7002 }, | ||
{ host: '127.0.0.1', port: 7003 }, | ||
{ host: '127.0.0.1', port: 7004 }, | ||
{ host: '127.0.0.1', port: 7005 }, | ||
] | ||
|
||
export const cluster = new Cluster(clusterNodes); | ||
export const redis = new Redis(); |