last_rendered

package
v0.0.0-...-8b9a2a1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxImageSizeBytes is the maximum size in bytes allowed for to-be-processed images.
	MaxImageSizeBytes int64 = 25 * 1024 * 1024
)

Variables

View Source
var (
	ErrMimeTypeUnsupported = errors.New("mime type unsupported")
)
View Source
var (
	ErrQueueFull = errors.New("queue full")
)

Functions

This section is empty.

Types

type LastRenderedProcessor

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

LastRenderedProcessor processes "last-rendered" images and stores them with the job.

func New

func New(storage Storage) *LastRenderedProcessor

func (*LastRenderedProcessor) JobHasImage

func (lrp *LastRenderedProcessor) JobHasImage(jobUUID string) bool

JobHasImage returns true only if the job actually has a last-rendered image. Only the lowest-resolution image is tested for. Since images are processed in order, existence of the last one should imply existence of all of them.

func (*LastRenderedProcessor) PathForJob

func (lrp *LastRenderedProcessor) PathForJob(jobUUID string) string

PathForJob returns the base path for this job's last-rendered images.

func (*LastRenderedProcessor) QueueImage

func (lrp *LastRenderedProcessor) QueueImage(payload Payload) error

QueueImage queues an image for processing. Returns `ErrQueueFull` if there is no more space in the queue for new images.

func (*LastRenderedProcessor) Run

func (lrp *LastRenderedProcessor) Run(ctx context.Context)

Run is the main loop for the processing of images. It will keep running until the context is closed.

func (*LastRenderedProcessor) ThumbSpecs

func (lrp *LastRenderedProcessor) ThumbSpecs() []Thumbspec

ThumbSpecs returns the thumbnail specifications.

type Payload

type Payload struct {
	JobUUID    string // Used to determine the directory to store the image.
	WorkerUUID string // Just for logging.
	MimeType   string
	Image      []byte

	// Callback is called when the image processing is finished.
	Callback func(ctx context.Context)
}

Payload contains the actual image to process.

type Storage

type Storage interface {
	// ForJob returns the directory path for storing job-related files.
	ForJob(jobUUID string) string
}

type Thumbspec

type Thumbspec struct {
	Filename  string
	MaxWidth  int
	MaxHeight int
}

Thumbspec specifies a thumbnail size & filename.

Jump to

Keyboard shortcuts

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