Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kannel channel paused when we get Queued message in response #670

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

norkans7
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (23e0c2a) 74.38% compared to head (e8096c0) 74.41%.

Files Patch % Lines
handlers/whatsapp_legacy/handler.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #670      +/-   ##
==========================================
+ Coverage   74.38%   74.41%   +0.03%     
==========================================
  Files          97       97              
  Lines       13082    13091       +9     
==========================================
+ Hits         9731     9742      +11     
+ Misses       2662     2660       -2     
  Partials      689      689              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

rc.Do("SET", rateLimitKey, "engaged")

// We pause sending 30 seconds so the connection to the SMSC is reset
rc.Do("EXPIRE", rateLimitKey, 30)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SET + EXPIRE = SETNX.. no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is deprecated https://redis.io/commands/setnx/

But I can do on line as rc.Do("SET", rateLimitKey, "engaged", "EX", 30)

if strings.Contains(string(respBody), "Queued") {
rc := h.Backend().RedisPool().Get()
defer rc.Close()
rateLimitKey := fmt.Sprintf("rate_limit:%s", msg.Channel().UUID())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't feel ideal having handlers talk directly to Redis to rate limit themselves and I see we only currently do this in the old WhatsApp onprem handler. And there's rate_limit_bulk.. don't we need to rate limit on both queues?

Maybe we need to have a think about making a cleaner way for channels to rate limit themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, we can find a new way tor that.

I do not think we need to pause the bulk queue in this case but I will double check on that again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added pausing the bulk queue as well

@norkans7 norkans7 force-pushed the kannel-pausing branch 2 times, most recently from 698d6c1 to f1227b1 Compare December 13, 2023 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants