worker

package
v0.0.0-...-e0658cb Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func NewAPI

func NewAPI(scheduler *Scheduler, libraryWriters map[string]libraries.LibraryWriter) *API

func (*API) ServeHTTP

func (a *API) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ArchiveOrgArchiver

type ArchiveOrgArchiver struct{}

type Archiver

type Archiver struct {
	ChromeArchiver     *ChromeArchiver
	ArchiveOrgArchiver *ArchiveOrgArchiver
	OpenGraphArchiver  *OpenGraphArchiver
}

type ChromeArchiver

type ChromeArchiver struct {
	SavePDF               bool
	SaveSinglefile        bool
	ScreenshotResolutions []Resolution
}

type Client

type Client struct {
	Endpoint string
	Client   *http.Client
}

func (*Client) GetJobRequest

func (c *Client) GetJobRequest(ctx context.Context) (*JobRequest, error)

type GetJobOptions

type GetJobOptions struct {
}

type Job

type Job struct {
	ID         string
	Library    string
	Deadline   time.Time
	URL        string
	Origin     string
	SnapshotID string
	Status     string
	Requested  time.Time
	Accepted   time.Time
	Started    time.Time
	Ended      time.Time
	Error      string
}

type JobClient

type JobClient struct {
	LibraryID  string
	Origin     string
	SnapshotID string
	Endpoint   string
	Token      string
	Client     *http.Client
}

func (*JobClient) Close

func (c *JobClient) Close() error

Close implements libraries.SnapshotWriter.

func (*JobClient) NextArtifactWriter

func (c *JobClient) NextArtifactWriter(ctx context.Context, name string) (libraries.ArtifactWriter, error)

NextArtifactWriter implements libraries.SnapshotWriter.

func (*JobClient) UpdateJob

func (c *JobClient) UpdateJob(ctx context.Context, job Job) error

func (*JobClient) WriteArtifact

func (c *JobClient) WriteArtifact(ctx context.Context, name string, data []byte) (int64, string, error)

WriteArtifact implements libraries.SnapshotWriter.

func (*JobClient) WriteArtifactManifest

func (c *JobClient) WriteArtifactManifest(ctx context.Context, manifest libraries.ArtifactManifest) error

WriteArtifactManifest implements libraries.SnapshotWriter.

type JobRequest

type JobRequest struct {
	Token    string
	Archiver Archiver
	Job      Job
}

type OpenGraphArchiver

type OpenGraphArchiver struct{}

type RemoteWorker

type RemoteWorker struct {
	JobRequests chan JobRequest
}

TODO: Naming

type Resolution

type Resolution string

func (Resolution) Rect

func (r Resolution) Rect() (int64, int64, error)

type Scheduler

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

func NewScheduler

func NewScheduler(indexer indexers.Indexer, libraryReaders map[string]libraries.LibraryReader, libraryWriters map[string]libraries.LibraryWriter) *Scheduler

func (*Scheduler) GetJobRequest

func (s *Scheduler) GetJobRequest(ctx context.Context, options *GetJobOptions) (*JobRequest, error)

func (*Scheduler) ScheduleSnapshot

func (s *Scheduler) ScheduleSnapshot(ctx context.Context, url string, strategy *Strategy) error

TODO: Support multiple libraries? What's the use case?

func (*Scheduler) UpdateJob

func (s *Scheduler) UpdateJob(ctx context.Context, job Job) error

type Strategy

type Strategy struct {
	Library   string
	Archivers []Archiver
}

type Worker

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

func NewWorker

func NewWorker(endpoint string) *Worker

TODO: For now the intent is to have a single code path for the embedded worker and remote workers for maintainability reasons. But we should consider supporting the embedded worker directly using the job channel and library, which could reduce memory usage by a fair bit given that there's no extra buffering involved

func (*Worker) Close

func (w *Worker) Close() error

func (*Worker) Shutdown

func (w *Worker) Shutdown() error

func (*Worker) Work

func (w *Worker) Work(ctx context.Context) error

Jump to

Keyboard shortcuts

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