mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-01-24 22:37:51 +00:00
Parallelize independent exact IP and CIDR gateway database queries to reduce latency in inbound call routing (#234)
This commit is contained in:
@@ -470,11 +470,13 @@ module.exports = (srf, logger) => {
|
||||
}
|
||||
|
||||
/* find all carrier entries that have an inbound gateway matching the source IP */
|
||||
/* Query both exact IP matches AND CIDR ranges to handle the case where
|
||||
/* Query both exact IP matches AND CIDR ranges in parallel to handle the case where
|
||||
multiple accounts have configured the same carrier with different netmasks.
|
||||
The phone number lookup will disambiguate which account owns the call. */
|
||||
const [gwExact] = await pp.query(sqlSelectExactGatewayForSP, [req.source_address]);
|
||||
const [gwCidr] = await pp.query(sqlSelectCIDRGatewaysForSP);
|
||||
const [[gwExact], [gwCidr]] = await Promise.all([
|
||||
pp.query(sqlSelectExactGatewayForSP, [req.source_address]),
|
||||
pp.query(sqlSelectCIDRGatewaysForSP)
|
||||
]);
|
||||
|
||||
/* Merge both result sets - exact matches first, then CIDR ranges (already sorted by netmask DESC) */
|
||||
const gw = [...gwExact, ...gwCidr];
|
||||
|
||||
Reference in New Issue
Block a user