Uh oh!
There was an error while loading. Please reload this page.
add rate limit for local backend, parse limit args - #1066
Conversation
ti-chi-bot
commented
Apr 27, 2021
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. DetailsReviewer can indicate their review by writing |
ti-chi-bot
commented
Apr 27, 2021
Welcome @recall704! |
sre-bot
commented
Apr 27, 2021
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
| replace cloud.google.com/go/storage => github.com/3pointer/google-cloud-go/storage v1.6.1-0.20210108125931-b59bfa0720b2 | ||
| replace ( | ||
| cloud.google.com/go/storage => github.com/3pointer/google-cloud-go/storage v1.6.1-0.20210108125931-b59bfa0720b2 | ||
| github.com/pingcap/kvproto v0.0.0-20210308063835-39b884695fb8 => github.com/recall704/kvproto v0.0.0-20210414071537-7bdfcba5f5d5 |
sre-bot
commented
Apr 27, 2021
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
kennytm
commented
Apr 28, 2021
Instead of adding a
The rate limiter should introduce a wrapper of |
recall704
commented
Apr 30, 2021
typewithRatelimitstruct {
ExternalStorageRatelimituint64// Byte/sec
}
// WithRatelimitfuncWithRatelimit(innerExternalStorage, ratelimituint64) ExternalStorage {
ifratelimit==0 {
returninner
}
return&withRatelimit{ExternalStorage: inner, Ratelimit: ratelimit}
}
func (r*withRatelimit) Create(ctx context.Context, namestring) (ExternalFileWriter, error) {
var (
writerExternalFileWritererrerror
)
iflocalStorage, ok:=r.ExternalStorage.(*LocalStorage); ok {
file, err:=os.Create(filepath.Join(localStorage.base, name))
iferr!=nil {
returnnil, errors.Trace(err)
}
buf:=bufio.NewWriter(file)
ifr.Ratelimit>0 {
w:=shapeio.NewWriterWithContext(buf, ctx)
w.SetRateLimit(float64(r.Ratelimit))
returnnewFlushStorageWriter(w, buf, file), nil
}
returnnewFlushStorageWriter(buf, buf, file), nil
}
writer, err=r.ExternalStorage.Create(ctx, name)
iferr!=nil {
returnnil, errors.Trace(err)
}
returnwriter, nil
}I try to use thanks |
kennytm
commented
May 5, 2021
@recall704 sorry for late reply, there's a week-long holiday in China and Japan 🙃.
you could just return a wrapper type that implements typewithRateLimitWriterstruct {
ExternalFileWriterRatelimituint64
}
func (r*withRatelimit) Create(ctx context.Context, namestring) (ExternalFileWriter, error) {
inner, err:=r.ExternalStorage.Create(ctx, name)
iferr!=nil {
returnnil, err
}
return&withRateLimitWriter{
ExternalFileWriter: inner,
Ratelimit: r.Ratelimit,
}, nil
}and then apply the Ratelimit in its func (rw*withRateLimitWriter) Write(ctx context.Context, p []byte) (int, error) {
// do rate limiting here.
}There's no need to figure out how to fit this into |
ti-chi-bot
commented
Jun 3, 2021
@recall704: PR needs rebase. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
sre-bot
commented
Jun 3, 2021
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
What problem does this PR solve?
add rate limit for local backend
What is changed and how it works?
set rate limit for
io.Writer