pkgsite: golang.org/x/pkgsite/internal/queue Index | Files

package queue

import "golang.org/x/pkgsite/internal/queue"

Package queue provides queue implementations that can be used for asynchronous scheduling of fetch actions.

Index

Package Files

queue.go

type GCP Uses

type GCP struct {
    // contains filtered or unexported fields
}

GCP provides a Queue implementation backed by the Google Cloud Tasks API.

func (*GCP) ScheduleFetch Uses

func (q *GCP) ScheduleFetch(ctx context.Context, modulePath, version, suffix string, taskIDChangeInterval time.Duration) (enqueued bool, err error)

ScheduleFetch enqueues a task on GCP to fetch the given modulePath and version. It returns an error if there was an error hashing the task name, or an error pushing the task to GCP. If the task was a duplicate, it returns (false, nil).

type InMemory Uses

type InMemory struct {
    // contains filtered or unexported fields
}

InMemory is a Queue implementation that schedules in-process fetch operations. Unlike the GCP task queue, it will not automatically retry tasks on failure.

This should only be used for local development.

func NewInMemory Uses

func NewInMemory(ctx context.Context, workerCount int, experiments []string, processFunc inMemoryProcessFunc) *InMemory

NewInMemory creates a new InMemory that asynchronously fetches from proxyClient and stores in db. It uses workerCount parallelism to execute these fetches.

func (*InMemory) ScheduleFetch Uses

func (q *InMemory) ScheduleFetch(ctx context.Context, modulePath, version, suffix string, taskIDChangeInterval time.Duration) (bool, error)

ScheduleFetch pushes a fetch task into the local queue to be processed asynchronously.

func (InMemory) WaitForTesting Uses

func (q InMemory) WaitForTesting(ctx context.Context)

WaitForTesting waits for all queued requests to finish. It should only be used by test code.

type Queue Uses

type Queue interface {
    ScheduleFetch(ctx context.Context, modulePath, version, suffix string, taskIDChangeInterval time.Duration) (bool, error)
}

A Queue provides an interface for asynchronous scheduling of fetch actions.

func New Uses

func New(ctx context.Context, cfg *config.Config, queueName string, numWorkers int, db *postgres.DB, processFunc inMemoryProcessFunc) (Queue, error)

New creates a new Queue with name queueName based on the configuration in cfg. When running locally, Queue uses numWorkers concurrent workers.

Package queue imports 14 packages (graph) and is imported by 6 packages. Updated 2020-09-18. Refresh now. Tools for package owners.