diff options
| author | Michael Matloob <matloob@golang.org> | 2023-07-31 18:24:14 -0400 |
|---|---|---|
| committer | Michael Matloob <matloob@golang.org> | 2023-08-04 19:24:02 +0000 |
| commit | 4434dd5c09d0bc36b9f8c6d94d092d88cbdfcf2e (patch) | |
| tree | 17f6566721bb9d8cc3342151d3a812926e269560 /internal/testing | |
| parent | 7ec3a4ee639385cfe278ad194c77be9484a330c9 (diff) | |
| download | go-x-pkgsite-4434dd5c09d0bc36b9f8c6d94d092d88cbdfcf2e.tar.xz | |
internal/frontend: add an interface for creating request caches
This change adds a new Cacher interface that is used to create
middlewares for caching requests. This abstracts away the use of redis
so that the frontend doesn't depend on redis. The tests still depend
on redis for the 404 page testing logic, but the 404 page logic will
be moved out into a different package so those tests will go too.
The Expirer and Middleware interfaces are not present on the Cache
function so that the interface can be defined in package
internal/frontend without needing the dependency on the Middleware
package.
For golang/go#61399
Change-Id: I6518b2ed1d772cb4deda3308c4190f0f1b8a35a0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/514518
kokoro-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'internal/testing')
| -rw-r--r-- | internal/testing/integration/frontend_test.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/testing/integration/frontend_test.go b/internal/testing/integration/frontend_test.go index f3cc6a4c..ceaea33f 100644 --- a/internal/testing/integration/frontend_test.go +++ b/internal/testing/integration/frontend_test.go @@ -46,7 +46,11 @@ func setupFrontend(ctx context.Context, t *testing.T, q queue.Queue, rc *redis.C t.Fatal(err) } mux := http.NewServeMux() - s.Install(mux.Handle, rc, nil) + var cacher frontend.Cacher + if rc != nil { + cacher = middleware.NewCacher(rc) + } + s.Install(mux.Handle, cacher, nil) // Get experiments from the context. Fully roll them out. expNames := experiment.FromContext(ctx).Active() |
