Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-02-08 03:39:50 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-02-08 03:39:53 +0300
commitde481bad5878862ae6f693190c3aa3d85242b2c9 (patch)
tree5295952727779ca2597dd897be85379e3d6f9fc8 /internal/vfs
parent9504871174848d6c3f47c6ba1d89899d1cd6c7f1 (diff)
Export MeteredRoundTripper
Exports the struct so that it can be asserted and adds a method that is called by the zip VFS.
Diffstat (limited to 'internal/vfs')
-rw-r--r--internal/vfs/zip/vfs.go29
1 files changed, 12 insertions, 17 deletions
diff --git a/internal/vfs/zip/vfs.go b/internal/vfs/zip/vfs.go
index b7055b01..29847ac9 100644
--- a/internal/vfs/zip/vfs.go
+++ b/internal/vfs/zip/vfs.go
@@ -8,13 +8,12 @@ import (
"sync"
"time"
- "gitlab.com/gitlab-org/gitlab-pages/internal/httpfs"
- "gitlab.com/gitlab-org/gitlab-pages/internal/httptransport"
-
"github.com/patrickmn/go-cache"
"gitlab.com/gitlab-org/gitlab-pages/internal/config"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/httpfs"
"gitlab.com/gitlab-org/gitlab-pages/internal/httprange"
+ "gitlab.com/gitlab-org/gitlab-pages/internal/httptransport"
"gitlab.com/gitlab-org/gitlab-pages/internal/vfs"
"gitlab.com/gitlab-org/gitlab-pages/metrics"
)
@@ -63,6 +62,14 @@ func New(cfg *config.ZipServing) vfs.VFS {
// TODO: make this timeout configurable
// https://gitlab.com/gitlab-org/gitlab-pages/-/issues/457
Timeout: 30 * time.Minute,
+ Transport: httptransport.NewMeteredRoundTripper(
+ httptransport.NewTransport(),
+ "zip_vfs",
+ metrics.HTTPRangeTraceDuration,
+ metrics.HTTPRangeRequestDuration,
+ metrics.HTTPRangeRequestsTotal,
+ httptransport.DefaultTTFBTimeout,
+ ),
},
}
@@ -96,25 +103,13 @@ func (fs *zipVFS) Reconfigure(cfg *config.Config) error {
}
func (fs *zipVFS) reconfigureTransport(cfg *config.Config) error {
- transport := httptransport.NewTransport()
-
fsTransport, err := httpfs.NewFileSystemPath(cfg.Zip.AllowedPaths)
if err != nil {
return err
}
- transport.RegisterProtocol("file", http.NewFileTransport(fsTransport))
-
- mrt := httptransport.NewMeteredRoundTripper(
- transport,
- "httprange_client",
- metrics.HTTPRangeTraceDuration,
- metrics.HTTPRangeRequestDuration,
- metrics.HTTPRangeRequestsTotal,
- httptransport.DefaultTTFBTimeout,
- )
-
- fs.httpClient.Transport = mrt
+ fs.httpClient.Transport.(*httptransport.MeteredRoundTripper).
+ RegisterProtocol("file", http.NewFileTransport(fsTransport))
return nil
}