-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add instrumentation file * singleton * fix tests --------- Co-authored-by: Andy Wang <[email protected]>
- Loading branch information
1 parent
4371dd0
commit 5ba5a9e
Showing
8 changed files
with
73 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Redis, Cluster as RedisCluster } from "ioredis"; | ||
|
||
type Messages = typeof en; | ||
|
||
declare global { | ||
var RedisClient: Redis | RedisCluster | undefined; | ||
} |
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,34 @@ | ||
export async function register() { | ||
console.log("🛠️ Starting Instrumentation registration..."); | ||
|
||
try { | ||
if ( | ||
typeof window === "undefined" && | ||
process.env.NEXT_RUNTIME === "nodejs" | ||
) { | ||
const { createRedisClient } = await import("./lib/redis"); | ||
|
||
if ( | ||
!process.env.REDIS_URL || | ||
!process.env.REDIS_USERNAME || | ||
!process.env.REDIS_PASSWORD | ||
) { | ||
return console.error( | ||
"🔴 Missing Redis configuration in instrumentation.ts", | ||
); | ||
} | ||
|
||
const redis = createRedisClient({ | ||
url: process.env.REDIS_URL, | ||
password: process.env.REDIS_PASSWORD, | ||
username: process.env.REDIS_USERNAME, | ||
}); | ||
|
||
global.RedisClient = redis; | ||
} | ||
} catch (error) { | ||
return console.error("🔴 Instrumentation registration error: ", error); | ||
} | ||
|
||
console.log("✅ Instrumentation registration complete."); | ||
} |
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