Skip to content

Commit 9f749d9

Browse files
committed
feat(api): Max conns can be configured through env
1 parent 916e47a commit 9f749d9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

apps/api/src/shared/config/config.service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class ConfigService {
2020
public static readonly OPENSUBTITLES_PASSWORD: string = 'OPENSUBTITLES_PASSWORD'
2121
public static readonly SUBTITLES_LANGUAGES: string = 'SUBTITLES_LANGUAGES'
2222
public static readonly MAX_CONCURRENT_DOWNLOADS: string = 'MAX_CONCURRENT_DOWNLOADS'
23+
public static readonly MAX_CONNS: string = 'MAX_CONNS'
2324
public static readonly TRAKT_KEY: string = 'TRAKT_KEY'
2425

2526
private readonly envConfig: { [key: string]: string }
@@ -111,6 +112,9 @@ export class ConfigService {
111112

112113
[ConfigService.MAX_CONCURRENT_DOWNLOADS]: Joi.number()
113114
.default(1),
115+
116+
[ConfigService.MAX_CONNS]: Joi.number()
117+
.default(35),
114118
})
115119

116120
const { error, value: validatedEnvConfig } = envVarsSchema.validate(envConfig, { stripUnknown: true })

apps/api/src/shared/torrent/torrent.service.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export class TorrentService implements OnApplicationBootstrap {
3333
*/
3434
private readonly maxConcurrent
3535

36+
/**
37+
* Maximum of concurrent connections
38+
*/
39+
private readonly maxConns
40+
3641
/**
3742
* All the different supported formats
3843
*/
@@ -93,6 +98,7 @@ export class TorrentService implements OnApplicationBootstrap {
9398
private readonly episodesService: EpisodesService
9499
) {
95100
this.maxConcurrent = this.configService.get(ConfigService.MAX_CONCURRENT_DOWNLOADS)
101+
this.maxConns = this.configService.get(ConfigService.MAX_CONNS)
96102
}
97103

98104
/**
@@ -117,7 +123,7 @@ export class TorrentService implements OnApplicationBootstrap {
117123
this.logger.log('Creating new WebTorrent client')
118124

119125
this.webTorrent = new WebTorrent({
120-
maxConns: 35
126+
maxConns: this.maxConns
121127
})
122128

123129
this.webTorrent.on('error', (err) => {

0 commit comments

Comments
 (0)