worker

package
v0.0.0-...-9944d71 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a worker client that communicates with the manager API

func NewClient

func NewClient(baseURL, workerID string) *Client

NewClient creates a new worker client

func (*Client) ClaimJob

func (c *Client) ClaimJob(ctx context.Context) (*domain.Job, error)

ClaimJob claims a pending job from the manager

func (*Client) CompleteJob

func (c *Client) CompleteJob(ctx context.Context, jobID uuid.UUID, placesScraped int) error

CompleteJob marks a job as completed

func (*Client) FailJob

func (c *Client) FailJob(ctx context.Context, jobID uuid.UUID, errMsg string) error

FailJob marks a job as failed

func (*Client) GetJob

func (c *Client) GetJob(ctx context.Context, jobID uuid.UUID) (*domain.Job, error)

GetJob fetches a specific job by ID from the manager

func (*Client) GetRandomProxy

func (c *Client) GetRandomProxy(ctx context.Context) (host string, port int, err error)

GetRandomProxy fetches a random healthy proxy from the manager for email validation

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context, status domain.WorkerStatus, currentJobID *uuid.UUID) error

Heartbeat sends a heartbeat to the manager

func (*Client) Register

func (c *Client) Register(ctx context.Context) (*domain.Worker, error)

Register registers the worker with the manager

func (*Client) ReleaseJob

func (c *Client) ReleaseJob(ctx context.Context, jobID uuid.UUID) error

ReleaseJob releases a job back to pending

func (*Client) SubmitResults

func (c *Client) SubmitResults(ctx context.Context, jobID uuid.UUID, data [][]byte) error

SubmitResults submits results to the manager

func (*Client) Unregister

func (c *Client) Unregister(ctx context.Context) error

Unregister unregisters the worker from the manager

type Config

type Config struct {
	ManagerURL   string
	WorkerID     string
	RunnerConfig *runner.Config
	RedisURL     string
	RedisAddr    string
	RedisPass    string
	RedisDB      int
	RabbitMQURL  string // RabbitMQ URL (preferred over Redis for job queue)
}

Config holds worker configuration

type MemoryWriter

type MemoryWriter struct {
	Results [][]byte
	// contains filtered or unexported fields
}

MemoryWriter is a ResultWriter that stores results in memory

func (*MemoryWriter) GetResults

func (w *MemoryWriter) GetResults() [][]byte

GetResults returns a copy of the stored results

func (*MemoryWriter) ResultCount

func (w *MemoryWriter) ResultCount() int

ResultCount returns the current number of results (thread-safe)

func (*MemoryWriter) Run

func (w *MemoryWriter) Run(ctx context.Context, in <-chan scrapemate.Result) error

Run implements scrapemate.ResultWriter

type Runner

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

Runner is a worker that claims and processes jobs from the manager

func NewRunner

func NewRunner(cfg *Config) (*Runner, error)

NewRunner creates a new worker runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

Run starts the worker

func (*Runner) Stop

func (r *Runner) Stop(ctx context.Context) error

Stop gracefully stops the worker

Jump to

Keyboard shortcuts

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