Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrConversionTimeout = errors.New("conversion timed out")
)
Functions ¶
func InitWorkers ¶
Types ¶
type Conversion ¶
type Conversion struct{}
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(s ConversionSource, 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.
type ConversionSource ¶
type ConversionSource struct { // URI represents the actual path to a remote (web) or local resource // to be converted. URI string // OriginalURI may contain the original path to a remote resource to be // converted if it is downloaded for local conversion. // This normally happens when the resource is an `octet-stream`. // It is only metadata, and it should NOT be used as the conversion source. OriginalURI string // Mime represents the content type of the source. It will be set to // `application/octet-stream` if it is unable to determine the type. // For more information see: // https://mimesniff.spec.whatwg.org/#matching-a-mime-type-pattern Mime string // IsLocal should be true if the URI relies on a local conversion strategy, // and false if the target is a remote source (that does not require // pre-processing). IsLocal bool }
ConversionSource contains the target resource path, and its MIME type. It may contain additional metadata about the conversion source.
func NewConversionSource ¶
NewConversionSource creates, and returns a new ConversionSource. It accepts either a URI to a remote resource or a reader containing a stream of bytes. If both parameters are specified, the reader takes precedence. The ConversionSource is prepared using one of two strategies: a local conversion (see rawSource) or a remote conversion (see uriSource).
func (ConversionSource) GetActualURI ¶
func (s ConversionSource) GetActualURI() string
GetActualURI returns the original conversion target. The URI field may not contain the original conversion target as it may be overwritten when using a local conversion strategy.
type UploadConversion ¶
type UploadConversion struct { Conversion AWSS3 }
type Work ¶
type Work struct {
// contains filtered or unexported fields
}
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 ¶
Error returns a channel that will be used for publishing errors from a conversion.