mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 16:27:22 +00:00
UBERF-8884 Use direct connection to database (#7426)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
e39094b3fe
commit
224d003d64
@ -44,10 +44,14 @@ export async function handleBlobGet (
|
|||||||
const { workspace, name } = request
|
const { workspace, name } = request
|
||||||
|
|
||||||
const cache = new LoggedCache(caches.default, metrics)
|
const cache = new LoggedCache(caches.default, metrics)
|
||||||
|
|
||||||
|
const cacheControl = request.headers.get('Cache-Control') ?? ''
|
||||||
|
if (!cacheControl.includes('no-cache')) {
|
||||||
const cached = await cache.match(request)
|
const cached = await cache.match(request)
|
||||||
if (cached !== undefined) {
|
if (cached !== undefined) {
|
||||||
return cached
|
return cached
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const { bucket } = selectStorage(env, workspace)
|
const { bucket } = selectStorage(env, workspace)
|
||||||
|
|
||||||
@ -75,9 +79,11 @@ export async function handleBlobGet (
|
|||||||
const response = new Response(object?.body, { headers, status })
|
const response = new Response(object?.body, { headers, status })
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
|
if (!cacheControl.includes('no-store')) {
|
||||||
const clone = metrics.withSync('response.clone', () => response.clone())
|
const clone = metrics.withSync('response.clone', () => response.clone())
|
||||||
ctx.waitUntil(cache.put(request, clone))
|
ctx.waitUntil(cache.put(request, clone))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,14 @@ export async function withPostgres<T> (
|
|||||||
fn: (db: BlobDB) => Promise<T>
|
fn: (db: BlobDB) => Promise<T>
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
const sql = metrics.withSync('db.connect', () => {
|
const sql = metrics.withSync('db.connect', () => {
|
||||||
return postgres(env.HYPERDRIVE.connectionString, {
|
return postgres(env.DB_URL, {
|
||||||
connection: {
|
connection: {
|
||||||
application_name: 'datalake'
|
application_name: 'datalake'
|
||||||
}
|
},
|
||||||
|
fetch_types: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const db = new LoggedDB(new PostgresDB(sql), metrics)
|
const db = new LoggedDB(new PostgresDB(sql), metrics)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
1
workers/datalake/worker-configuration.d.ts
vendored
1
workers/datalake/worker-configuration.d.ts
vendored
@ -12,6 +12,7 @@ interface Env {
|
|||||||
STREAMS_ACCOUNT_ID: string;
|
STREAMS_ACCOUNT_ID: string;
|
||||||
STREAMS_AUTH_KEY: string;
|
STREAMS_AUTH_KEY: string;
|
||||||
R2_ACCOUNT_ID: string;
|
R2_ACCOUNT_ID: string;
|
||||||
|
DB_URL: string;
|
||||||
DATALAKE_APAC_ACCESS_KEY: string;
|
DATALAKE_APAC_ACCESS_KEY: string;
|
||||||
DATALAKE_APAC_SECRET_KEY: string;
|
DATALAKE_APAC_SECRET_KEY: string;
|
||||||
DATALAKE_APAC_BUCKET_NAME: string;
|
DATALAKE_APAC_BUCKET_NAME: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user