internal: remove experiment frontend-fetch
This is the final step for removing the frontend-fetch experiment flag.
The signature for pathFoundAtLatestError is also updated, and the
function is renamed to legacyPathFoundAtLatestError, since this is now
only used by the legacy code.
For golang/go#39629
Change-Id: I254664d2b57fbe10652471a586ef1b4268355890
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/255344
Trust: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/experiment.go b/internal/experiment.go
index 60f4961..1627317 100644
--- a/internal/experiment.go
+++ b/internal/experiment.go
@@ -10,23 +10,21 @@
)
const (
- ExperimentAutocomplete = "autocomplete"
- ExperimentFrontendFetch = "frontend-fetch"
- ExperimentSidenav = "sidenav"
- ExperimentUnitPage = "unit-page"
- ExperimentUseUnits = "use-units"
- ExperimentUsePathInfo = "use-path-info"
+ ExperimentAutocomplete = "autocomplete"
+ ExperimentSidenav = "sidenav"
+ ExperimentUnitPage = "unit-page"
+ ExperimentUseUnits = "use-units"
+ ExperimentUsePathInfo = "use-path-info"
)
// Experiments represents all of the active experiments in the codebase and
// a description of each experiment.
var Experiments = map[string]string{
- ExperimentAutocomplete: "Enable autocomplete with search.",
- ExperimentFrontendFetch: "Enable ability to fetch a package that doesn't exist on pkg.go.dev.",
- ExperimentSidenav: "Display documentation index on the left sidenav.",
- ExperimentUnitPage: "Enable the redesigned details page.",
- ExperimentUseUnits: "Read from paths, documentation, readmes, and package_imports tables.",
- ExperimentUsePathInfo: "Check the paths table if a path exists, as opposed to the packages or modules table.",
+ ExperimentAutocomplete: "Enable autocomplete with search.",
+ ExperimentSidenav: "Display documentation index on the left sidenav.",
+ ExperimentUnitPage: "Enable the redesigned details page.",
+ ExperimentUseUnits: "Read from paths, documentation, readmes, and package_imports tables.",
+ ExperimentUsePathInfo: "Check the paths table if a path exists, as opposed to the packages or modules table.",
}
// Experiment holds data associated with an experimental feature for frontend
diff --git a/internal/frontend/details.go b/internal/frontend/details.go
index bdbe0d0..9d444d9 100644
--- a/internal/frontend/details.go
+++ b/internal/frontend/details.go
@@ -386,12 +386,9 @@
}
}
-// pathFoundAtLatestError returns an error page when the fullPath exists, but
+// legacyPathFoundAtLatestError returns an error page when the fullPath exists, but
// the version that is requested does not.
-func pathFoundAtLatestError(ctx context.Context, pathType, fullPath, requestedVersion string) error {
- if isActiveFrontendFetch(ctx) {
- return pathNotFoundError(fullPath, requestedVersion)
- }
+func legacyPathFoundAtLatestError(pathType, fullPath, requestedVersion string) error {
return &serverError{
status: http.StatusNotFound,
epage: &errorPage{
diff --git a/internal/frontend/fetch.go b/internal/frontend/fetch.go
index 18f1ba0..c48b3a1 100644
--- a/internal/frontend/fetch.go
+++ b/internal/frontend/fetch.go
@@ -21,7 +21,6 @@
"golang.org/x/mod/module"
"golang.org/x/pkgsite/internal"
"golang.org/x/pkgsite/internal/derrors"
- "golang.org/x/pkgsite/internal/experiment"
"golang.org/x/pkgsite/internal/fetch"
"golang.org/x/pkgsite/internal/log"
"golang.org/x/pkgsite/internal/postgres"
@@ -525,10 +524,6 @@
return http.StatusOK, nil
}
-func isActiveFrontendFetch(ctx context.Context) bool {
- return experiment.IsActive(ctx, internal.ExperimentFrontendFetch)
-}
-
func recordFrontendFetchMetric(ctx context.Context, status int, latency time.Duration) {
l := float64(latency) / float64(time.Millisecond)
diff --git a/internal/frontend/legacy_module.go b/internal/frontend/legacy_module.go
index 9a281a6..89aa03f 100644
--- a/internal/frontend/legacy_module.go
+++ b/internal/frontend/legacy_module.go
@@ -41,7 +41,7 @@
if requestedVersion != internal.LatestVersion {
_, err = ds.LegacyGetModuleInfo(ctx, modulePath, internal.LatestVersion)
if err == nil {
- return pathFoundAtLatestError(ctx, "module", modulePath, displayVersion(requestedVersion, modulePath))
+ return legacyPathFoundAtLatestError("module", modulePath, displayVersion(requestedVersion, modulePath))
}
if !errors.Is(err, derrors.NotFound) {
log.Errorf(ctx, "error checking for latest module: %v", err)
diff --git a/internal/frontend/legacy_package.go b/internal/frontend/legacy_package.go
index fa5fb37..aab14b1 100644
--- a/internal/frontend/legacy_package.go
+++ b/internal/frontend/legacy_package.go
@@ -57,7 +57,7 @@
}
_, err = ds.LegacyGetPackage(ctx, pkgPath, modulePath, internal.LatestVersion)
if err == nil {
- return pathFoundAtLatestError(ctx, "package", pkgPath, requestedVersion)
+ return legacyPathFoundAtLatestError("package", pkgPath, requestedVersion)
}
if !errors.Is(err, derrors.NotFound) {
// Unlike the error handling for LegacyGetDirectory above, we don't serve an