web

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 15 Imported by: 0

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")
)

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"`
	MaxTime  time.Duration `json:"max_time"`
	Proxies  []string      `json:"proxies"`
}

func (*JobData) Validate

func (d *JobData) Validate() error

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 SelectParams

type SelectParams struct {
	Status string
	Limit  int
}

type Server

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

func New

func New(svc *Service) (*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) GetCSV

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

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