Repository
Carousel
Receives queued leads from CandyMuncher and prepares them for routing.
Archive location. Dodol/Carousel. Purpose based on README.md and handlers/leadReceiverHandler.js at 7d8c364.
What the history shows
The separate CarouselMatcher repository begins with Muhammad Anwaar’s 19 December 2019 commit c9594d1. Carousel’s December revision 73c51b2 records the other side of that split by removing its Lambda matcher and scheduling code.
When a lead was missing from Carousel’s Redis state, the mobile app needed to distinguish a lead that had already been assigned. Commit 6a35371 checks CandyMuncher for that assignment before replying.
How the lead router worked
- Asynchronous handoffs. CandyMuncher sent start and stop commands over SQS. CarouselMatcher invoked Presence asynchronously to send an offer. See
CandyMuncher/services/LeadRouter/LeadRouter.jsat789f7b2andCarouselMatcher/app/lib/Presence.jsat6a3368f. - Where the services depended on each other. Carousel, CarouselMatcher, and Presence shared Redis keys for live routing and salesperson state. The matcher read eligibility and routing policy from CandyBase. On the response path, Presence waited for Carousel’s reply, and Carousel waited for CandyMuncher to confirm acceptance before clearing the lead from its queues. Direct assignments from CarouselMatcher also went to CandyMuncher. See
Presence/app/lib/Carousel.jsat998c1f2,Carousel/handlers/routingResponsesHandler.jsat7d8c364, andCarouselMatcher/app/lib/CandyBase.jsandapp/worker.jsat6a3368f. - Logging on a separate queue. Carousel published offer outcomes and errors, and CarouselMatcher published direct assignments. RoutingLogger consumed these SQS messages in batches and wrote them to CandyBase. The lead and tenant IDs tied the records to the routing flow. Timestamps let it measure how long a lead waited to be offered and how long a reply took. See
Carousel/handlers/lib/RoutingLogger.jsat7d8c364,CarouselMatcher/app/lib/RoutingLogger.jsat6a3368f, andRoutingLogger/handlers/newLogsHandler.jsatde484b3.
How Redis coordinated routing
CandyMuncher sent routing commands to Carousel over SQS and received callbacks about lead status. Carousel and CarouselMatcher used Redis for the live routing state, alongside the salesperson connection state written by Presence. See CandyMuncher/services/LeadRouter/LeadRouter.js, Carousel/handlers/leadReceiverHandler.js at 7d8c364, and Presence/app/lib/Redis.js.
- Wake a tenant’s worker when work arrives. Carousel stored a new lead in a Redis waiting queue scored by the time it could start routing. It then deleted the tenant’s sleep key. The worker checked that key during its backoff and could resume before its sleep timer expired. See
Carousel/handlers/lib/Redis.jsat7d8c364andCarouselMatcher/app/worker.jsat6a3368f. - Track the offer on both sides. Before asking Presence to deliver an offer, CarouselMatcher checked the salesperson’s live connection record in Redis and skipped people with an active offer. It recorded the new offer against both the lead and the salesperson. If the offer was rejected or timed out, Carousel cleared the salesperson’s offer marker and moved the lead back to pending, unless routing had been stopped. See
CarouselMatcher/app/lib/Redis.jsat6a3368fandCarousel/handlers/routingResponsesHandler.jsat7d8c364.
Development history
-
2019
From Lambda to a dedicated matcher
-
Carousel implements lead matching
Muhammad Anwaar committed the first implementation of Carousel with lead routing rules.
f11653d -
SQS becomes the matcher trigger
After Muhammad Anwaar configured SQS events and Reza Rosli added delayed messages for the next run, Reza made the queue the sole trigger for the Lambda matcher.
f0140b17a1d2feabad655 -
Matching moves to CarouselMatcher
We tried lead matching in Lambda before moving it into a separate worker. Muhammad Anwaar started the separate CarouselMatcher repository in December. Reza removed the matcher from Carousel, which kept lead intake and offer responses.
73c51b2
-
Primary contributor
Reza Rosli · 195 authored commits
Added an assignment lookup when a lead was absent from the routing cache and refined when ingestion woke the matcher.
Example revisions 6a35371 (), 906f4d8 ().
When contributors were active
Authored commits per quarter through Q1 2023, oldest first. Rows are ordered by the first quarter with activity. Brighter cells show more commits. Scroll across to see later quarters.
| Contributor | 2019 Q1 | 2019 Q2 | 2019 Q3 | 2019 Q4 | 2020 Q1 | 2020 Q2 | 2020 Q3 | 2020 Q4 | 2021 Q1 | 2021 Q2 | 2021 Q3 | 2021 Q4 | 2022 Q1 | 2022 Q2 | 2022 Q3 | 2022 Q4 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Muhammad Anwaar 68 commits · 2019 Q1–2020 Q1 | 1 | 7 | 55 | 4 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Reza Rosli 195 commits · 2019 Q3–2022 Q4 | 0 | 0 | 64 | 44 | 32 | 8 | 8 | 19 | 17 | 0 | 0 | 2 | 0 | 0 | 0 | 1 |