@@ -268,8 +268,8 @@ async function saveAllocations(
268268}
269269
270270type SupplierAllocationResult = {
271- supplier : string ;
272271 priority : string ;
272+ supplier : string ;
273273} ;
274274
275275async function processSupplierAllocation (
@@ -331,13 +331,13 @@ async function processSupplierAllocation(
331331 } ) ,
332332 ) ;
333333 return {
334- supplier,
335334 priority,
335+ supplier,
336336 } ;
337337}
338338
339339export default function createSupplierAllocatorHandler ( deps : Deps ) : SQSHandler {
340- const getSupplierIdempotently = (
340+ const createGetSupplierIdempotently = (
341341 perAllocationSuccess : AllocationMetrics ,
342342 perAllocationFailure : AllocationMetrics ,
343343 volumeGroupAllocations : VolumeGroupAllocation ,
@@ -363,8 +363,8 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
363363 const perAllocationFailure : AllocationMetrics = new Map ( ) ;
364364 const volumeGroupAllocations : VolumeGroupAllocation = new Map ( ) ;
365365
366- // create an idempotent function bound to this handler's batchItemFailures
367- const boundGetSupplierIdempotently = getSupplierIdempotently (
366+ // create an idempotent function bound to this handler's global variables to track metrics and allocations
367+ const getSupplierIdempotently = createGetSupplierIdempotently (
368368 perAllocationSuccess ,
369369 perAllocationFailure ,
370370 volumeGroupAllocations ,
@@ -387,10 +387,9 @@ export default function createSupplierAllocatorHandler(deps: Deps): SQSHandler {
387387 idempotencyConfig . registerLambdaContext ( context ) ;
388388
389389 const supplierAllocationResult : SupplierAllocationResult =
390- await boundGetSupplierIdempotently ( letterEvent , deps ) ;
390+ await getSupplierIdempotently ( letterEvent , deps ) ;
391391
392- supplier = supplierAllocationResult . supplier ;
393- priority = supplierAllocationResult . priority ;
392+ ( { priority, supplier } = supplierAllocationResult ) ;
394393 } catch ( error ) {
395394 deps . logger . error ( {
396395 description : "Error processing allocation of record" ,
0 commit comments