fetchserver

package
v0.0.0-...-86cb477 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2024 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// FetchLatencyDistribution aggregates frontend fetch request
	// latency by status code.
	FetchLatencyDistribution = &view.View{
		Name:    "go-discovery/frontend-fetch/latency",
		Measure: frontendFetchLatency,

		Aggregation: view.Distribution(
			1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100,
			130, 160, 200, 250, 300, 400, 500, 650, 800, 1000,
			30*60,
			60*60),
		Description: "FrontendFetch latency, by result source query type.",
		TagKeys:     []tag.Key{keyFetchStatus},
	}
	// FetchResponseCount counts frontend fetch responses by response type.
	FetchResponseCount = &view.View{
		Name:        "go-discovery/frontend-fetch/count",
		Measure:     frontendFetchLatency,
		Aggregation: view.Count(),
		Description: "Frontend fetch request count",
		TagKeys:     []tag.Key{keyFetchStatus},
	}
)

Functions

func FetchAndUpdateState

func FetchAndUpdateState(ctx context.Context, modulePath, requestedVersion string, proxyClient *proxy.Client, sourceClient *source.Client, db internal.PostgresDB) (_ int, err error)

FetchAndUpdateState is used by the InMemory queue for testing in internal/frontend and running cmd/frontend locally. It is a copy of worker.FetchAndUpdateState that does not update module_version_states, so that we don't have to import internal/worker here. It is not meant to be used when running on AppEngine.

Types

type FetchServer

type FetchServer struct {
	Queue                queue.Queue
	TaskIDChangeInterval time.Duration
}

func (*FetchServer) ServeFetch

func (s *FetchServer) ServeFetch(w http.ResponseWriter, r *http.Request, ds internal.DataSource) (err error)

serveFetch checks if a requested path and version exists in the database. If not, it will enqueue potential module versions that could contain the requested path and version to a task queue, to be fetched by the worker. Meanwhile, the request will poll the database until a row is found, or a timeout occurs. A status and responseText will be returned based on the result of the request.

func (*FetchServer) ServePathNotFoundPage

func (s *FetchServer) ServePathNotFoundPage(w http.ResponseWriter, r *http.Request,
	db internal.PostgresDB, fullPath, modulePath, requestedVersion string) (err error)

servePathNotFoundPage serves a 404 page for the requested path, or redirects the user to an appropriate location.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL