migrate token pooling to postgres (#8922)

* add ability to store token pool in Postgres DB

* update transitive ansi-regex dependencies
This commit is contained in:
chris48s
2023-02-23 17:18:39 +00:00
committed by GitHub
parent ec8d739099
commit 091ccfdbcd
16 changed files with 743 additions and 71 deletions

View File

@@ -1,5 +1,6 @@
import { AuthHelper } from '../../core/base-service/auth-helper.js'
import RedisTokenPersistence from '../../core/token-pooling/redis-token-persistence.js'
import SqlTokenPersistence from '../../core/token-pooling/sql-token-persistence.js'
import log from '../../core/server/log.js'
import GithubApiProvider from './github-api-provider.js'
import { setRoutes as setAcceptorRoutes } from './auth/acceptor.js'
@@ -23,8 +24,18 @@ class GithubConstellation {
this._debugEnabled = config.service.debug.enabled
this._debugIntervalSeconds = config.service.debug.intervalSeconds
const { redis_url: redisUrl, gh_token: globalToken } = config.private
if (redisUrl) {
const {
postgres_url: pgUrl,
redis_url: redisUrl,
gh_token: globalToken,
} = config.private
if (pgUrl) {
log.log('Token persistence configured with dbUrl')
this.persistence = new SqlTokenPersistence({
url: pgUrl,
table: 'github_user_tokens',
})
} else if (redisUrl) {
log.log('Token persistence configured with redisUrl')
this.persistence = new RedisTokenPersistence({
url: redisUrl,