Skip to content

Commit 9560dc9

Browse files
committedDec 8, 2021
Add comment about the 2 seconds pause choice
1 parent 46317fa commit 9560dc9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed
 

‎handlers/whatsapp/whatsapp.go

+4
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,10 @@ func sendWhatsAppMsg(rc redis.Conn, msg courier.Msg, sendPath *url.URL, payload
847847
if rr.StatusCode == 429 || rr.StatusCode == 503 {
848848
rateLimitKey := fmt.Sprintf("rate_limit:%s", msg.Channel().UUID().String())
849849
rc.Do("set", rateLimitKey, "engaged")
850+
851+
// The rate limit is 50 requests per second
852+
// We pause sending 2 seconds so the limit count is reset
853+
// TODO: In the future we should the header value when available
850854
rc.Do("expire", rateLimitKey, 2)
851855

852856
log := courier.NewChannelLogFromRR("rate limit engaged", msg.Channel(), msg.ID(), rr).WithError("Message Send Error", err)

0 commit comments

Comments
 (0)
Please sign in to comment.