fix poll lock + metrics
All checks were successful
Build and push image for doorman-homeassistant / diff (push) Successful in 11s
Build and push Doorman UI / API / diff (push) Successful in 11s
Build and push image for doorman-homeassistant / docker (push) Has been skipped
Build and push image for doorman-homeassistant / deploy-gitainer (push) Has been skipped
Build and push Doorman UI / API / twilio (push) Successful in 2m49s
All checks were successful
Build and push image for doorman-homeassistant / diff (push) Successful in 11s
Build and push Doorman UI / API / diff (push) Successful in 11s
Build and push image for doorman-homeassistant / docker (push) Has been skipped
Build and push image for doorman-homeassistant / deploy-gitainer (push) Has been skipped
Build and push Doorman UI / API / twilio (push) Successful in 2m49s
This commit is contained in:
parent
8aa1fa7b08
commit
09231cd7f7
@ -87,25 +87,26 @@ export const handler: ServerlessFunctionSignature<TwilioContext, BuzzerDialEvent
|
||||
|
||||
const unlockPromise = new Promise<VoiceResponse>((resolve, reject) => {
|
||||
intervals.push(setInterval(() => {
|
||||
// prevent multiple polling at once
|
||||
if (pollLock) {
|
||||
return;
|
||||
}
|
||||
|
||||
getMetricFromRegistry<Counter>(metricsRegistry, BuzzerActivatedMetrics.POLL_ATTEMPTS)
|
||||
.inc({ door: config.door }, 1);
|
||||
|
||||
const recordPollLatency = getMetricFromRegistry<Summary>(metricsRegistry, BuzzerActivatedMetrics.POLL_LATENCY)
|
||||
.startTimer({ door: config.door });
|
||||
|
||||
// prevent multiple polling at once
|
||||
if (pollLock) {
|
||||
return;
|
||||
}
|
||||
|
||||
pollLock = true;
|
||||
fetch(context.DOORMAN_URL + `/api/door/status?door=${config.door}`)
|
||||
.then(res => res.json())
|
||||
.then(async (rawBody) => {
|
||||
let body = rawBody as StatusResponse;
|
||||
recordPollLatency();
|
||||
pollLock = false;
|
||||
|
||||
if (body?.status === DoorStatus.OPEN) {
|
||||
pollLock = false;
|
||||
clearInterval(intervals[0]);
|
||||
const twiml = doorOpenTwiml(config);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user