-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#12): add integration test + feedback
- Loading branch information
1 parent
0ea2be0
commit cf89625
Showing
19 changed files
with
266 additions
and
234 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
import Redis from 'ioredis'; | ||
import { env } from 'process'; | ||
|
||
const environment = env as unknown as { | ||
REDIS_HOST: string; | ||
REDIS_PORT: string; | ||
}; | ||
|
||
export const WorkerConfig = { | ||
redisConnection: { | ||
host: environment.REDIS_HOST, | ||
port: Number(environment.REDIS_PORT), | ||
}, | ||
moveContactQueue: 'MOVE_CONTACT_QUEUE', | ||
}; | ||
|
||
const assertRedisConfig = () => { | ||
const {host, port} = WorkerConfig.redisConnection; | ||
if (!host) { | ||
throw new Error('REDIS_HOST is not defined'); | ||
} | ||
if (!port || isNaN(port) || port <= 0) { | ||
throw new Error('REDIS_PORT is not defined or invalid'); | ||
} | ||
}; | ||
|
||
export const checkRedisConnection = async () => { | ||
assertRedisConfig(); | ||
|
||
const config = WorkerConfig.redisConnection; | ||
const redis = new Redis(config.port, config.host, {lazyConnect: true}); | ||
try { | ||
await redis.connect(); | ||
} catch (error : any) { | ||
throw new Error(`Failed to connect to Redis at ${config.host}:${config.port}: ${error}`); | ||
} finally { | ||
redis?.disconnect(); | ||
} | ||
}; |
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
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
Oops, something went wrong.