converter

package
v0.0.0-...-5f7c3e1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConversionTimeout = errors.New("conversion timed out")
)

Functions

func InitWorkers

func InitWorkers(maxWorkers, maxQueue, t int) chan<- Work

Types

type AWSS3

type AWSS3 struct {
	Region       string
	AccessKey    string
	AccessSecret string
	S3Bucket     string
	S3Key        string
}

type Conversion

type Conversion struct {
	// Path is the URI to the resource to be converted.
	Path string
}

Conversion represents the most basic, skeleton conversion job. Currently, it is assumed that the input is a HTML (or similar) resource, and the output is a PDF. Conversion implements the Converter interface with dummy methods. Any child conversion type should overwrite these methods.

func (Conversion) Convert

func (c Conversion) Convert(done <-chan struct{}) ([]byte, error)

Convert should return a byte slice containing the converted resource, synchronously. It should terminate any long-running processes (and Goroutines) if the done channel is returned.

func (Conversion) Upload

func (c Conversion) Upload(b []byte) (bool, error)

Upload should take a byte slice, and return a boolean indicating if the data was used for post-processing, e.g. uploading to a remote host like S3. It should always return false if there is an error.

type Converter

type Converter interface {
	Convert(<-chan struct{}) ([]byte, error)
	Upload([]byte) (bool, error)
}

type UploadConversion

type UploadConversion struct {
	Conversion
	AWSS3
}

func (UploadConversion) Upload

func (c UploadConversion) Upload(b []byte) (bool, error)

type Work

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

func NewWork

func NewWork(wq chan<- Work, c Converter) Work

func (Work) Cancel

func (w Work) Cancel()

Cancel will close the done channel. This will indicate to child Goroutines that the job has been terminated, and the results are no longer needed.

func (Work) Cancelled

func (w Work) Cancelled() <-chan struct{}

Cancelled returns a channel that will indicate when a job has been completed.

func (Work) Error

func (w Work) Error() <-chan error

Error returns a channel that will be used for publishing errors from a conversion.

func (Work) Process

func (w Work) Process(t int)

func (Work) Success

func (w Work) Success() <-chan []byte

Success returns a channel that will be used for publishing the output of a conversion.

func (Work) Uploaded

func (w Work) Uploaded() <-chan struct{}

Uploaded returns a channel that will be closed when a conversion has been uploaded.

type Worker

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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