pkgsite: Index | Files

package worker

import ""

Package worker provides functionality for running a worker service. Its primary operation is to fetch modules from a proxy and write them to the database.


Package Files

completion.go fetch.go memory.go pages.go server.go


var (

    // EnqueueResponseCount counts worker enqueue responses by response type.
    EnqueueResponseCount = &view.View{
        Name:        "go-discovery/worker-enqueue/count",
        Measure:     enqueueStatus,
        Aggregation: view.Count(),
        Description: "Worker enqueue request count",
        TagKeys:     []tag.Key{keyEnqueueStatus},
var ProxyRemoved = map[string]bool{}

ProxyRemoved is a set of module@version that have been removed from the proxy, even though they are still in the index.

func FetchAndUpdateState Uses

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

FetchAndUpdateState fetches and processes a module version, and then updates the module_version_states table according to the result. It returns an HTTP status code representing the result of the fetch operation, and a non-nil error if this status code is not 200.

type Server Uses

type Server struct {
    // contains filtered or unexported fields

Server can be installed to serve the go discovery worker.

func NewServer Uses

func NewServer(cfg *config.Config, scfg ServerConfig) (_ *Server, err error)

NewServer creates a new Server with the given dependencies.

func (*Server) Install Uses

func (s *Server) Install(handle func(string, http.Handler))

Install registers server routes using the given handler registration func.

type ServerConfig Uses

type ServerConfig struct {
    DB                   *postgres.DB
    IndexClient          *index.Client
    ProxyClient          *proxy.Client
    SourceClient         *source.Client
    RedisHAClient        *redis.Client
    RedisCacheClient     *redis.Client
    Queue                queue.Queue
    ReportingClient      *errorreporting.Client
    TaskIDChangeInterval time.Duration
    StaticPath           template.TrustedSource
    GetExperiments       func() []*internal.Experiment

ServerConfig contains everything needed by a Server.

Package worker imports 43 packages (graph) and is imported by 1 packages. Updated 2020-10-28. Refresh now. Tools for package owners.