entity

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: BSD-4-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type File

type File struct {
	ID       uuid.UUID
	Name     string
	MimeType string
	Size     int64
	Data     []byte
	Created  time.Time
}

func NewFile

func NewFile(name string, data []byte) File

type Format

type Format uint8
const (
	FormatHeaders Format = iota
	FormatSingleFile
	FormatPDF
)

type Page

type Page struct {
	ID          uuid.UUID
	URL         string
	Description string
	Created     time.Time
	Formats     []Format
	Results     Results
	Version     uint16
	Status      Status
}

func NewPage

func NewPage(url string, description string, formats ...Format) *Page

func (*Page) Process

func (p *Page) Process(ctx context.Context, processor Processor)

func (*Page) SetProcessing

func (p *Page) SetProcessing()

type Pages

type Pages interface {
	Save(ctx context.Context, page *Page) error
}

type Processor

type Processor interface {
	Process(ctx context.Context, format Format, url string) Result
}

type Result

type Result struct {
	Format Format
	Err    error
	Files  []File
}

type Results

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

func (*Results) Add

func (r *Results) Add(result Result)

func (*Results) MarshalMsgpack

func (r *Results) MarshalMsgpack() ([]byte, error)

func (*Results) Results

func (r *Results) Results() []Result

func (*Results) UnmarshalMsgpack

func (r *Results) UnmarshalMsgpack(b []byte) error

type Status

type Status uint8
const (
	StatusNew Status = iota
	StatusProcessing
	StatusDone
	StatusFailed
	StatusWithErrors
)

type Worker

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

func NewWorker

func NewWorker(ch chan *Page, pages Pages, processor Processor, log *zap.Logger) *Worker

func (*Worker) Start

func (w *Worker) Start(ctx context.Context, wg *sync.WaitGroup)

Jump to

Keyboard shortcuts

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