web

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 19 Imported by: ? 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

View Source
const (
	StatusPending = "pending"
	StatusWorking = "working"
	StatusOK      = "ok"
	StatusFailed  = "failed"
)

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrAlreadyExists = errors.New("already exists")
)
View Source
var ErrPlacesNotFound = errors.New("places not found")

ErrPlacesNotFound is returned by GetPlaces when the job's CSV output does not exist. Callers use it to distinguish a missing job (404) from other errors.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID     string
	Name   string
	Date   time.Time
	Status string
	Data   JobData
}

func (*Job) Validate

func (j *Job) Validate() error

type JobData

type JobData struct {
	Keywords     []string      `json:"keywords"`
	Lang         string        `json:"lang"`
	Zoom         int           `json:"zoom"`
	Lat          string        `json:"lat"`
	Lon          string        `json:"lon"`
	FastMode     bool          `json:"fast_mode"`
	Radius       int           `json:"radius"`
	Depth        int           `json:"depth"`
	Email        bool          `json:"email"`
	ExtraReviews bool          `json:"extra_reviews"`
	MaxTime      time.Duration `json:"max_time"`
	Proxies      []string      `json:"proxies"`
}

func (*JobData) Validate

func (d *JobData) Validate() error

type JobPage added in v1.18.0

type JobPage struct {
	Jobs        []Job
	CurrentPage int
	TotalPages  int
	Total       int
	HasPrev     bool
	HasNext     bool
	PrevPage    int
	NextPage    int
	HasPages    bool
}

JobPage contains one page of jobs and the metadata needed to navigate it.

type JobRepository

type JobRepository interface {
	Get(context.Context, string) (Job, error)
	Create(context.Context, *Job) error
	Delete(context.Context, string) error
	Select(context.Context, SelectParams) ([]Job, error)
	Update(context.Context, *Job) error
}

type Place added in v1.17.2

type Place struct {
	Title        string  `json:"title"`
	Address      string  `json:"address"`
	Latitude     float64 `json:"latitude"`
	Longitude    float64 `json:"longitude"`
	Link         string  `json:"link"`
	Category     string  `json:"category"`
	Phone        string  `json:"phone"`
	Website      string  `json:"website"`
	ReviewRating float64 `json:"review_rating"`
}

Place is a single map-able result extracted from a job's CSV output.

type SelectParams

type SelectParams struct {
	Status string
	Limit  int
	Offset int
}

type Server

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

func New

func New(svc *Service, addr string) (*Server, error)

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

type Service

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

func NewService

func NewService(repo JobRepository, dataFolder string) *Service

func (*Service) All

func (s *Service) All(ctx context.Context) ([]Job, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, job *Job) error

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

func (*Service) Get added in v1.7.0

func (s *Service) Get(ctx context.Context, id string) (Job, error)

func (*Service) GetCSV

func (s *Service) GetCSV(_ context.Context, id string) (string, error)

func (*Service) GetPlaces added in v1.17.2

func (s *Service) GetPlaces(_ context.Context, id string) ([]Place, error)

GetPlaces locates the job's CSV output and parses it into mappable places. In web mode each job writes exactly one {id}.csv, so that file is the single source of truth for the map.

func (*Service) ListJobs added in v1.18.0

func (s *Service) ListJobs(ctx context.Context, page, limit int) (JobPage, error)

ListJobs returns a page of jobs, clamping invalid page and limit values.

func (*Service) SelectPending

func (s *Service) SelectPending(ctx context.Context) ([]Job, error)

func (*Service) Update

func (s *Service) Update(ctx context.Context, job *Job) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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