• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-client-gateway / 14059069490

25 Mar 2025 12:01PM UTC coverage: 90.569% (+0.07%) from 90.499%
14059069490

push

github

hectorgomezv
refactor: remove redis commands timeout

3183 of 3813 branches covered (83.48%)

Branch coverage included in aggregate %.

21 of 26 new or added lines in 3 files covered. (80.77%)

1 existing line in 1 file now uncovered.

10895 of 11731 relevant lines covered (92.87%)

535.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.31
/src/datasources/cache/cache.module.ts
1
import { Global, Module } from '@nestjs/common';
110✔
2
import { createClient } from 'redis';
110✔
3
import { IConfigurationService } from '@/config/configuration.service.interface';
110✔
4
import { CacheService } from '@/datasources/cache/cache.service.interface';
110✔
5
import { RedisCacheService } from '@/datasources/cache/redis.cache.service';
110✔
6
import { CacheReadiness } from '@/domain/interfaces/cache-readiness.interface';
110✔
7
import { ILoggingService, LoggingService } from '@/logging/logging.interface';
110✔
8
import { CacheKeyPrefix } from '@/datasources/cache/constants';
110✔
9
import { LogType } from '@/domain/common/entities/log-type.entity';
110✔
10

11
export type RedisClientType = ReturnType<typeof createClient>;
12

13
async function redisClientFactory(
14
  configurationService: IConfigurationService,
15
  loggingService: ILoggingService,
16
): Promise<RedisClientType> {
17
  const redisUser = configurationService.get<string>('redis.user');
4✔
18
  const redisPass = configurationService.get<string>('redis.pass');
4✔
19
  const redisHost = configurationService.getOrThrow<string>('redis.host');
4✔
20
  const redisPort = configurationService.getOrThrow<string>('redis.port');
4✔
21
  const redisConnectTimeout = configurationService.getOrThrow<number>(
4✔
22
    'redis.connectTimeout',
23
  );
24
  const redisDisableOfflineQueue = configurationService.getOrThrow<boolean>(
4✔
25
    'redis.disableOfflineQueue',
26
  );
27
  const client: RedisClientType = createClient({
4✔
28
    socket: {
29
      host: redisHost,
30
      port: Number(redisPort),
31
      connectTimeout: redisConnectTimeout,
32
    },
33
    username: redisUser,
34
    password: redisPass,
35
    disableOfflineQueue: redisDisableOfflineQueue,
36
  });
37
  client.on('error', (err) =>
4✔
NEW
38
    loggingService.error({
×
39
      type: LogType.CacheError,
40
      source: 'CacheModule',
41
      message: err.code ?? err.message,
×
42
    }),
43
  );
44
  client.on('reconnecting', () =>
4✔
NEW
45
    loggingService.warn({
×
46
      type: LogType.CacheEvent,
47
      source: 'CacheModule',
48
      message: 'Reconnecting to Redis',
49
    }),
50
  );
51
  client.on('end', () =>
4✔
52
    loggingService.warn({
4✔
53
      type: LogType.CacheEvent,
54
      source: 'CacheModule',
55
      message: 'Redis connection closed',
56
    }),
57
  );
58
  await client.connect();
4✔
59
  return client;
4✔
60
}
61

62
@Global()
63
@Module({
64
  providers: [
65
    {
66
      provide: 'RedisClient',
67
      useFactory: redisClientFactory,
68
      inject: [IConfigurationService, LoggingService],
69
    },
70
    { provide: CacheService, useClass: RedisCacheService },
71
    { provide: CacheReadiness, useExisting: CacheService },
72
    { provide: CacheKeyPrefix, useValue: '' },
73
  ],
74
  exports: [CacheService, CacheReadiness],
75
})
76
export class CacheModule {}
110✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc