Adds HTTP Get rate limitation on cache

We don't want to have a large bandwidth on bedetheque.com, so the pace
at which we perform GET request is limited by a maximal number of
request over a window (per example no more than 10 request over 10
second)

If more request are required, the request is simply paused until we go
back within the limit ;). Go rulez !
This commit is contained in:
2016-01-17 19:05:30 +01:00
parent b58b7e7e6a
commit c070c63463
3 changed files with 67 additions and 13 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"io/ioutil"
"os"
"time"
. "gopkg.in/check.v1"
)
@@ -30,7 +31,7 @@ func (s *AlbumDescriptionCacheSuite) TestCanFetchCache(c *C) {
c.Assert(err, IsNil)
defer os.RemoveAll(tmpdir)
cache, err := NewAlbumDescriptionCache(tmpdir)
cache, err := NewAlbumDescriptionCache(tmpdir, 10, 10*time.Second)
c.Assert(err, IsNil)
for ID, expected := range data {