ratelimits: Implement batched Spends and Refunds#7143
Merged
Conversation
04a05bd to
6b70047
Compare
6b70047 to
c96c473
Compare
18 tasks
996f652 to
e1fe8a4
Compare
e1fe8a4 to
6f4bd2a
Compare
731b8a1 to
f8c6528
Compare
f41cd06 to
14920cd
Compare
14920cd to
4e42b79
Compare
0e5b7d5 to
7d2d757
Compare
fddb710 to
32e393a
Compare
03136d6 to
798a61f
Compare
798a61f to
0adf3fa
Compare
jsha
requested changes
Nov 28, 2023
jsha
requested changes
Nov 30, 2023
jsha
left a comment
Contributor
There was a problem hiding this comment.
Partial review but I wanted to get something across the table before the end of the (east coast) day. Will keep reviewing.
jsha
requested changes
Dec 1, 2023
62ae5a4 to
6f6ec22
Compare
941293e to
7fd825b
Compare
jsha
approved these changes
Dec 5, 2023
|
|
||
| tats := make(map[string]time.Time, len(bucketKeys)) | ||
| for i, result := range results { | ||
| tatNano, err := result.(*redis.StringCmd).Int64() |
Contributor
There was a problem hiding this comment.
Is each result documented to definitely be of type *redis.StringCmd? If not, this should use the , ok type assertion and return error if it's the wrong type.
Member
Author
There was a problem hiding this comment.
Correct. Specifically, each executed Pipeline command is documented to return a specific result type:
A few lines above we queue multiple Get() commands:
pipeline := r.client.Pipeline()
for _, bucketKey := range bucketKeys {
pipeline.Get(ctx, bucketKey)
}The function signature of the Get() command:
func (redis.StringCmdable).Get(ctx context.Context, key string) *redis.StringCmd
aarongable
approved these changes
Dec 6, 2023
pgporada
reviewed
Dec 6, 2023
|
|
||
| domains = DomainsForRateLimiting([]string{"www.example.com", "example.com", "www.example.co.uk"}) | ||
| test.AssertDeepEquals(t, domains, []string{"example.co.uk", "example.com"}) | ||
|
|
Member
There was a problem hiding this comment.
Suggested change
| domains = DomainsForRateLimiting([]string{"example.com", "example.com"}) | |
| test.AssertDeepEquals(t, domains, []string{"example.com"}) | |
The function description states that it also de-duplicates the output domains.
pgporada
approved these changes
Dec 6, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #5545
Ideally
ratelimits/bucket.goshould be renamedratelimits/transaction.gobut that will make the diff harder to review. We can do the rename in a follow-up.