Skip to content

Commit 326093a

Browse files
author
Uros Marolt
authored
webhook api shouldnt kill db client connections at all (#1853)
1 parent 773eb72 commit 326093a

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

backend/src/segment/track.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { getServiceChildLogger } from '@crowd/logging'
22
import { Edition } from '@crowd/types'
33
import { API_CONFIG, IS_TEST_ENV, SEGMENT_CONFIG } from '../conf'
4-
import getTenatUser from './trackHelper'
5-
import addProductData, { CROWD_ANALYTICS_PLATORM_NAME } from './addProductDataToCrowdTenant'
64
import SequelizeRepository from '../database/repositories/sequelizeRepository'
5+
import { CROWD_ANALYTICS_PLATORM_NAME } from './addProductDataToCrowdTenant'
6+
import getTenatUser from './trackHelper'
77

88
const log = getServiceChildLogger('segment')
99

services/apps/webhook_api/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ setImmediate(async () => {
2020

2121
const sqsClient = getSqsClient(SQS_CONFIG())
2222

23-
const dbConnection = await getDbConnection(DB_CONFIG(), 3)
23+
const dbConnection = await getDbConnection(DB_CONFIG(), 3, 0)
2424

2525
app.use((req, res, next) => {
2626
// Groups.io doesn't send a content-type header,

services/libs/database/src/connection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ let dbConnection: DbConnection | undefined
4747
export const getDbConnection = async (
4848
config: IDatabaseConfig,
4949
maxPoolSize?: number,
50+
idleTimeoutMillis?: number,
5051
): Promise<DbConnection> => {
5152
if (dbConnection) {
5253
return dbConnection
@@ -62,6 +63,7 @@ export const getDbConnection = async (
6263
dbConnection = dbInstance({
6364
...config,
6465
max: maxPoolSize || 20,
66+
idleTimeoutMillis: idleTimeoutMillis !== undefined ? idleTimeoutMillis : 10000,
6567
// query_timeout: 30000,
6668
application_name: process.env.SERVICE || 'unknown-app',
6769
})

0 commit comments

Comments
 (0)