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

WA tiers paused #413

Merged
merged 5 commits into from
Feb 3, 2022
Merged

WA tiers paused #413

merged 5 commits into from
Feb 3, 2022

Conversation

norkans7
Copy link
Contributor

@norkans7 norkans7 commented Feb 3, 2022

No description provided.

@codecov
Copy link

codecov bot commented Feb 3, 2022

Codecov Report

Merging #413 (6ea5e12) into main (58a64d9) will decrease coverage by 0.06%.
The diff coverage is 27.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #413      +/-   ##
==========================================
- Coverage   71.95%   71.89%   -0.07%     
==========================================
  Files          95       95              
  Lines        8348     8357       +9     
==========================================
+ Hits         6007     6008       +1     
- Misses       1747     1753       +6     
- Partials      594      596       +2     
Impacted Files Coverage Δ
queue/queue.go 72.00% <ø> (ø)
handlers/whatsapp/whatsapp.go 76.90% <27.27%> (-1.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58a64d9...6ea5e12. Read the comment docs.

@norkans7 norkans7 changed the title Wa tiers paused WA tiers paused Feb 3, 2022
queue/queue.go Outdated
@@ -123,6 +123,14 @@ var luaPop = redis.NewScript(2, `-- KEYS: [EpochMS QueueType]

-- if we didn't find one, try again from our bulk queue
if not result[1] or isFutureResult then
-- check if we are paused for bulk queue
local pausedBulkKey = "paused_bulk:" .. queueName
Copy link
Member

Choose a reason for hiding this comment

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

maybe we call this rate_limit_bulk so we have a way to rate limit everything and a way to rate limit just bulk sends

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so replace paused_bulk with rate_limit_bulk?

Copy link
Member

Choose a reason for hiding this comment

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

yeah

@@ -1022,6 +1034,15 @@ func buildWhatsAppHeaders(channel courier.Channel) http.Header {
return header
}

func hasTiersError(payload mtErrorPayload) bool {
for _, err := range payload.Errors {
if err.Code == 471 && err.Title == "Spam rate limit hit" {
Copy link
Member

Choose a reason for hiding this comment

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

is it important to check error title? Just wondering if that can change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove that

@@ -60,6 +60,19 @@ func TestLua(t *testing.T) {
delay := time.Second*2 - time.Duration(time.Now().UnixNano()%int64(time.Second))
time.Sleep(delay)

conn.Do("set", "paused_bulk:chan1", "engaged")
conn.Do("EXPIRE", "paused_bulk:chan1", 5)
Copy link
Member

Choose a reason for hiding this comment

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

let's start a convention of using UPPERCASE for redis commands

@norkans7 norkans7 requested a review from rowanseymour February 3, 2022 17:54
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