Skip to content

Commit

Permalink
fix(db): connection with pooling
Browse files Browse the repository at this point in the history
  • Loading branch information
ful1e5 committed Nov 16, 2023
1 parent adc27b8 commit da70b83
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Node.js and Yarn
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Node.js and Yarn
uses: actions/setup-node@v3
Expand Down
3 changes: 2 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ generator client {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
url = env("POSTGRES_PRISMA_URL") // uses connection pooling
directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}

enum Role {
Expand Down
11 changes: 5 additions & 6 deletions src/services/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ export class ImageRedis {
}

private __connect() {
const client = new Redis({
const client: Redis = new Redis({
host: process.env.REDIS_HOST,
port: process.env.REDIS_PORT,
password: process.env.REDIS_PASSWORD,
lazyConnect: true,
tls: {}
lazyConnect: true
});
client.on('ready', () => {
console.info('Redis cluster Ready');
Expand All @@ -39,8 +38,8 @@ export class ImageRedis {
}

public async saveSVGs(key: RedisKey, value: SVG[]) {
return await this.client.set(key, JSON.stringify(value), (s) => {
console.info(`Updated Type '${key}': ${s} `);
await this.client.set(key, JSON.stringify(value), (s) => {
s && console.info(`Updated Type '${key}': ${s} `);
});
}

Expand All @@ -54,7 +53,7 @@ export class ImageRedis {

public async saveUrls(key: RedisKey, name: string, urls: (string | null)[]) {
return await this.client.set(key, JSON.stringify(urls), (s) => {
console.info(`Updated '${name}': ${s} `);
s && console.info(`Updated '${name}': ${s} `);
});
}
}

0 comments on commit da70b83

Please sign in to comment.