entity

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Cache added in v0.1.4

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

func NewCache added in v0.1.4

func NewCache() *Cache

func (*Cache) Get added in v0.1.4

func (c *Cache) Get() []byte

func (*Cache) Reader added in v0.1.4

func (c *Cache) Reader() io.Reader

func (*Cache) Write added in v0.1.4

func (c *Cache) Write(p []byte) (n int, err error)

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 Meta added in v0.1.3

type Meta struct {
	Title       string
	Description string
	Encoding    string
	Error       string
}

type Page

type Page struct {
	PageBase
	Results ResultsRO
	// contains filtered or unexported fields
}

func NewPage

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

func (*Page) Prepare added in v0.1.6

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

func (*Page) Process

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

func (*Page) SetProcessing

func (p *Page) SetProcessing()

type PageBase added in v0.1.4

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

type Pages

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

type Processor

type Processor interface {
	Process(ctx context.Context, format Format, url string, cache *Cache) Result
	GetMeta(ctx context.Context, url string, cache *Cache) (Meta, error)
}

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) RO added in v0.1.4

func (r *Results) RO() ResultsRO

func (*Results) Results

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

func (*Results) UnmarshalMsgpack

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

type ResultsRO added in v0.1.4

type ResultsRO []Result

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