Skip to content

Commit

Permalink
Merge pull request #785 from nyaruka/new_queue_name
Browse files Browse the repository at this point in the history
Use 'tasks:handler' queue name instead of 'handler'
  • Loading branch information
rowanseymour authored Sep 12, 2024
2 parents 2109642 + 23ca741 commit c49abf9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions backends/rapidpro/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,17 +1501,17 @@ func (ts *BackendTestSuite) assertNoQueuedContactTask(contactID ContactID) {
rc := ts.b.rp.Get()
defer rc.Close()

assertredis.ZCard(ts.T(), rc, "handler:1", 0)
assertredis.ZCard(ts.T(), rc, "handler:active", 0)
assertredis.ZCard(ts.T(), rc, "tasks:handler:1", 0)
assertredis.ZCard(ts.T(), rc, "tasks:handler:active", 0)
assertredis.LLen(ts.T(), rc, fmt.Sprintf("c:1:%d", contactID), 0)
}

func (ts *BackendTestSuite) assertQueuedContactTask(contactID ContactID, expectedType string, expectedBody map[string]any) {
rc := ts.b.rp.Get()
defer rc.Close()

assertredis.ZCard(ts.T(), rc, "handler:1", 1)
assertredis.ZCard(ts.T(), rc, "handler:active", 1)
assertredis.ZCard(ts.T(), rc, "tasks:handler:1", 1)
assertredis.ZCard(ts.T(), rc, "tasks:handler:active", 1)
assertredis.LLen(ts.T(), rc, fmt.Sprintf("c:1:%d", contactID), 1)

data, err := redis.Bytes(rc.Do("LPOP", fmt.Sprintf("c:1:%d", contactID)))
Expand Down
8 changes: 4 additions & 4 deletions backends/rapidpro/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func queueMailroomTask(rc redis.Conn, taskType string, orgID OrgID, contactID Co

// we do all our queueing in a transaction
contactQueue := fmt.Sprintf("c:%d:%d", orgID, contactID)
rc.Send("multi")
rc.Send("rpush", contactQueue, eventJSON)
rc.Send("zadd", fmt.Sprintf("handler:%d", orgID), fmt.Sprintf("%.5f", epochFloat-10000000), contactJSON)
rc.Send("zincrby", "handler:active", 0, orgID)
rc.Send("MULTI")
rc.Send("RPUSH", contactQueue, eventJSON)
rc.Send("ZADD", fmt.Sprintf("tasks:handler:%d", orgID), fmt.Sprintf("%.5f", epochFloat-10000000), contactJSON)
rc.Send("ZINCRBY", "tasks:handler:active", 0, orgID)
_, err = rc.Do("EXEC")

return err
Expand Down

0 comments on commit c49abf9

Please sign in to comment.