8000 fix: [#625] Throttle doesn't work when using the Redis cache driver by hwbrzzl · Pull Request #955 · goravel/framework · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: [#625] Throttle doesn't work when using the Redis cache driver #955

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

merged 10 commits into from
Mar 14, 2025

Conversation

hwbrzzl
Copy link
Contributor
@hwbrzzl hwbrzzl commented Mar 12, 2025

📑 Description

Closes goravel/goravel#625

✅ Checks

  • Added test cases for my code

Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 23482c8 Previous: ab139f2 Ratio
Benchmark_EncryptString 6751 ns/op 2160 B/op 15 allocs/op 2299 ns/op 2160 B/op 15 allocs/op 2.94
Benchmark_EncryptString - ns/op 6751 ns/op 2299 ns/op 2.94
Benchmark_DecryptString 6659 ns/op 2040 B/op 17 allocs/op 2100 ns/op 2040 B/op 17 allocs/op 3.17
Benchmark_DecryptString - ns/op 6659 ns/op 2100 ns/op 3.17

This comment was automatically generated by workflow using github-action-benchmark.

Copy link
codecov bot commented Mar 14, 2025

Codecov Report

Attention: Patch coverage is 77.77778% with 34 lines in your changes missing coverage. Please review.

Please upload report for BASE (v1.15.x@d05e842). Learn more about missing BASE report.

Files with missing lines Patch % Lines
http/limit/limit.go 0.00% 11 Missing ⚠️
http/service_provider.go 0.00% 10 Missing ⚠️
http/middleware/throttle.go 0.00% 6 Missing ⚠️
http/limit/store.go 94.87% 2 Missing and 2 partials ⚠️
cache/lock.go 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v1.15.x     #955   +/-   ##
==========================================
  Coverage           ?   68.60%           
==========================================
  Files              ?      219           
  Lines              ?    18957           
  Branches           ?        0           
==========================================
  Hits               ?    13006           
  Misses             ?     5284           
  Partials           ?      667           

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

nb := NewBucket(s.tokens, s.interval)
if err := s.cache.Put(key, nb, s.interval); err != nil {
Copy link
Contributor Author
@hwbrzzl hwbrzzl Mar 14, 2025

Choose a reason for hiding this comment

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

The bug is caused by this line, struct can't be stored in Redis directly, Put will return an error here. It means this feature can't be used entirely when using the Redis driver. Through this thing, I think the next major work is to improve test coverage, before more people use the framework. cc @goravel/core-developers

@hwbrzzl hwbrzzl marked this pull request as ready for review March 14, 2025 08:09
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 14, 2025 08:09
devhaozi
devhaozi previously approved these changes Mar 14, 2025
Copy link
Member
@devhaozi devhaozi left a comment

Choose a reason for hiding this comment

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

LGTM

return r.BlockWithTicker(t, 1*time.Second, callback...)
}

func (r *Lock) BlockWithTicker(t time.Duration, ti time.Duration, callback ...func()) bool {
Copy link
Contributor Author
@hwbrzzl hwbrzzl Mar 14, 2025

Choose a reason for hiding this comment

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

Previously, the default ticker is 1 second, we want to customize the ticker in Throttle. Otherwise, the request will very slow when checking throttle (1s * N).

@hwbrzzl hwbrzzl merged commit 9f0f6a6 into v1.15.x Mar 14, 2025
10 of 11 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#625 branch March 14, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0