MCPcopy Index your code
hub / github.com/rclone/rclone / openRateLimited

Method openRateLimited

backend/cache/cache.go:1763–1778  ·  view source on GitHub ↗

openRateLimited will execute a closure under a rate limiter watch

(fn func() (io.ReadCloser, error))

Source from the content-addressed store, hash-verified

1761
1762// openRateLimited will execute a closure under a rate limiter watch
1763func (f *Fs) openRateLimited(fn func() (io.ReadCloser, error)) (io.ReadCloser, error) {
1764 var err error
1765 ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
1766 defer cancel()
1767 start := time.Now()
1768
1769 if err = f.rateLimiter.Wait(ctx); err != nil {
1770 return nil, err
1771 }
1772
1773 elapsed := time.Since(start)
1774 if elapsed > time.Second*2 {
1775 fs.Debugf(f, "rate limited: %s", elapsed)
1776 }
1777 return fn()
1778}
1779
1780// CleanUpCache will cleanup only the cache data that is expired
1781func (f *Fs) CleanUpCache(ignoreLastTs bool) {

Callers 1

readerMethod · 0.80

Calls 2

DebugfFunction · 0.92
WaitMethod · 0.65

Tested by

no test coverage detected