Skip to content

Commit

Permalink
updated db config
Browse files Browse the repository at this point in the history
  • Loading branch information
soloseng committed Aug 29, 2023
1 parent b761d9e commit 2bfb83d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
34 changes: 20 additions & 14 deletions packages/phone-number-privacy/combiner/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@ import {
RETRY_DELAY_IN_MS,
rootLogger,
TestUtils,
toBool,
} from '@celo/phone-number-privacy-common'
import {
blockchainApiKey,
blockchainProvider,
dbHost,
dbName,
dbPassword,
dbPoolMaxSize,
dbPort,
dbSsl,
dbTimeout,
dbType,
dbUsername,
domainEnabled,
domainFullNodeDelaysMs,
domainFullNodeRetryCount,
Expand Down Expand Up @@ -79,7 +89,7 @@ export interface CombinerConfig {
phoneNumberPrivacy: OdisConfig
domains: OdisConfig
db: {
type: SupportedDatabase
type: SupportedDatabase | string
user: string
password: string
database: string
Expand Down Expand Up @@ -234,19 +244,15 @@ if (DEV_MODE) {
fullNodeRetryDelayMs: domainFullNodeDelaysMs.value(),
},
db: {
type: functionConfig.db.type
? functionConfig.db.type.toLowerCase()
: SupportedDatabase.Postgres,
user: functionConfig.db.username,
password: functionConfig.db.pass,
database: functionConfig.db.name,
host: `/cloudsql/${functionConfig.db.host}`,
port: functionConfig.db.port ? Number(functionConfig.db.port) : undefined,
ssl: toBool(functionConfig.db.ssl, true),
poolMaxSize: functionConfig.db.pool_max_size
? Number(functionConfig.db.pool_max_size)
: DB_POOL_MAX_SIZE,
timeout: functionConfig.db.timeout ? Number(functionConfig.db.timeout) : DB_TIMEOUT,
type: dbType.value(),
user: dbUsername.value(),
password: dbPassword.value(),
database: dbName.value(),
host: `/cloudsql/${dbHost.value()}`,
port: dbPort.value(),
ssl: dbSsl.value(),
poolMaxSize: dbPoolMaxSize.value(),
timeout: dbTimeout.value(),
},
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import {
DB_POOL_MAX_SIZE,
DB_TIMEOUT,
FULL_NODE_TIMEOUT_IN_MS,
RETRY_COUNT,
RETRY_DELAY_IN_MS,
} from '@celo/phone-number-privacy-common'
import { defineBoolean, defineInt, defineSecret, defineString } from 'firebase-functions/params'
import { SupportedDatabase } from '../config'

const defaultServiceName = 'odis-combiner'

Expand Down Expand Up @@ -65,3 +68,14 @@ export const domainFullNodeRetryCount = defineInt('DOMAIN_FULL_NODE_RETRY_COUNT'
export const domainFullNodeDelaysMs = defineInt('DOMAIN_FULL_NODE_DELAY_MS', {
default: RETRY_DELAY_IN_MS,
})

// DB
export const dbType = defineString('DB_TYPE', { default: SupportedDatabase.Postgres.toString() })
export const dbUsername = defineString('DB_USERNAME')
export const dbPassword = defineSecret('DB_PASSWORD')
export const dbName = defineString('DB_NAME')
export const dbHost = defineString('DB_HOST')
export const dbPort = defineInt('DB_PORT', { default: undefined })
export const dbSsl = defineBoolean('DB_SSL', { default: true })
export const dbPoolMaxSize = defineInt('DB_POOL_MAX_SIZE', { default: DB_POOL_MAX_SIZE })
export const dbTimeout = defineInt('DB_TIMEOUT', { default: DB_TIMEOUT })

0 comments on commit 2bfb83d

Please sign in to comment.