mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-14 20:39:03 +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,9 +44,13 @@ export async function handleBlobGet (
|
||||
const { workspace, name } = request
|
||||
|
||||
const cache = new LoggedCache(caches.default, metrics)
|
||||
const cached = await cache.match(request)
|
||||
if (cached !== undefined) {
|
||||
return cached
|
||||
|
||||
const cacheControl = request.headers.get('Cache-Control') ?? ''
|
||||
if (!cacheControl.includes('no-cache')) {
|
||||
const cached = await cache.match(request)
|
||||
if (cached !== undefined) {
|
||||
return cached
|
||||
}
|
||||
}
|
||||
|
||||
const { bucket } = selectStorage(env, workspace)
|
||||
@ -75,8 +79,10 @@ export async function handleBlobGet (
|
||||
const response = new Response(object?.body, { headers, status })
|
||||
|
||||
if (response.status === 200) {
|
||||
const clone = metrics.withSync('response.clone', () => response.clone())
|
||||
ctx.waitUntil(cache.put(request, clone))
|
||||
if (!cacheControl.includes('no-store')) {
|
||||
const clone = metrics.withSync('response.clone', () => response.clone())
|
||||
ctx.waitUntil(cache.put(request, clone))
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
|
@ -50,12 +50,14 @@ export async function withPostgres<T> (
|
||||
fn: (db: BlobDB) => Promise<T>
|
||||
): Promise<T> {
|
||||
const sql = metrics.withSync('db.connect', () => {
|
||||
return postgres(env.HYPERDRIVE.connectionString, {
|
||||
return postgres(env.DB_URL, {
|
||||
connection: {
|
||||
application_name: 'datalake'
|
||||
}
|
||||
},
|
||||
fetch_types: false
|
||||
})
|
||||
})
|
||||
|
||||
const db = new LoggedDB(new PostgresDB(sql), metrics)
|
||||
|
||||
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_AUTH_KEY: string;
|
||||
R2_ACCOUNT_ID: string;
|
||||
DB_URL: string;
|
||||
DATALAKE_APAC_ACCESS_KEY: string;
|
||||
DATALAKE_APAC_SECRET_KEY: string;
|
||||
DATALAKE_APAC_BUCKET_NAME: string;
|
||||
|
Loading…
Reference in New Issue
Block a user