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

safe-global / safe-client-gateway / 14061484132

25 Mar 2025 01:57PM UTC coverage: 90.566% (+0.07%) from 90.499%
14061484132

push

github

web-flow
refactor: remove redis commands timeout (#2498)

3179 of 3809 branches covered (83.46%)

Branch coverage included in aggregate %.

20 of 25 new or added lines in 3 files covered. (80.0%)

1 existing line in 1 file now uncovered.

10894 of 11730 relevant lines covered (92.87%)

535.88 hits per line

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

78.57
/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 redisDisableOfflineQueue = configurationService.getOrThrow<boolean>(
4✔
22
    'redis.disableOfflineQueue',
23
  );
24
  const client: RedisClientType = createClient({
4✔
25
    socket: {
26
      host: redisHost,
27
      port: Number(redisPort),
28
    },
29
    username: redisUser,
30
    password: redisPass,
31
    disableOfflineQueue: redisDisableOfflineQueue,
32
  });
33
  client.on('error', (err) =>
4✔
NEW
34
    loggingService.error({
×
35
      type: LogType.CacheError,
36
      source: 'CacheModule',
37
      message: err.code ?? err.message,
×
38
    }),
39
  );
40
  client.on('reconnecting', () =>
4✔
NEW
41
    loggingService.warn({
×
42
      type: LogType.CacheEvent,
43
      source: 'CacheModule',
44
      message: 'Reconnecting to Redis',
45
    }),
46
  );
47
  client.on('end', () =>
4✔
48
    loggingService.warn({
4✔
49
      type: LogType.CacheEvent,
50
      source: 'CacheModule',
51
      message: 'Redis connection closed',
52
    }),
53
  );
54
  await client.connect();
4✔
55
  return client;
4✔
56
}
57

58
@Global()
59
@Module({
60
  providers: [
61
    {
62
      provide: 'RedisClient',
63
      useFactory: redisClientFactory,
64
      inject: [IConfigurationService, LoggingService],
65
    },
66
    { provide: CacheService, useClass: RedisCacheService },
67
    { provide: CacheReadiness, useExisting: CacheService },
68
    { provide: CacheKeyPrefix, useValue: '' },
69
  ],
70
  exports: [CacheService, CacheReadiness],
71
})
72
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