Skip to content

Commit 4802a72

Browse files
committed
review: initialize assetProxy outside function so it runs during lamba init phase
1 parent ac302f9 commit 4802a72

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/lambdas/ingest/index.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,12 @@ import getObjectJson from '../../lib/s3-utils.js'
66
import logger from '../../lib/logger.js'
77
import { AssetProxy } from '../../lib/asset-proxy.js'
88

9-
let assetProxyInstance = null
9+
let assetProxy = new AssetProxy()
10+
await assetProxy.initialize()
1011

11-
const getAssetProxy = async () => {
12-
if (!assetProxyInstance) {
13-
assetProxyInstance = new AssetProxy()
14-
await assetProxyInstance.initialize()
15-
}
16-
17-
return assetProxyInstance
18-
}
19-
20-
export const resetAssetProxy = () => {
21-
assetProxyInstance = null
12+
export const resetAssetProxy = async () => {
13+
assetProxy = new AssetProxy()
14+
await assetProxy.initialize()
2215
}
2316

2417
const isSqsEvent = (event) => 'Records' in event
@@ -92,7 +85,7 @@ export const handler = async (event, _context) => {
9285

9386
if (postIngestTopicArn) {
9487
logger.debug('Publishing to post-ingest topic: %s', postIngestTopicArn)
95-
const assetProxy = await getAssetProxy()
88+
// const assetProxy = await getAssetProxy()
9689
await publishResultsToSns(results, postIngestTopicArn, assetProxy)
9790
} else {
9891
logger.debug('Skipping post-ingest notification since no topic is configured')

0 commit comments

Comments
 (0)