job

package
v0.0.0-...-ec9fd1c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2012 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package job specifies a consistent description of a render job.

Index

Constants

View Source
const (
	StatusNew StatusCode = 0

	StatusRendering = 100
	StatusReading   = 101
	StatusUpdating  = 102
	StatusWriting   = 103

	StatusDone = 200

	StatusError = 500
)
View Source
const DefaultFormat = "png"

Variables

View Source
var FormatMap = map[string]Format{
	"png":  Format{".png", png.Encode},
	"jpeg": Format{".jpg", func(w io.Writer, i image.Image) error { return jpeg.Encode(w, i, nil) }},
}

Functions

This section is empty.

Types

type Format

type Format struct {
	Extension string
	Encode    func(io.Writer, image.Image) error
}

A Format holds information about how to encode an job's image.

type Job

type Job struct {
	Name      string
	Source    io.Reader
	Params    yamlscene.Params
	SceneLog  log.Logger
	RenderLog log.Logger
	// contains filtered or unexported fields
}

func New

func New(name string, source io.Reader, params yamlscene.Params) (job *Job)

New returns a newly allocated job structure.

func (*Job) ChangeStatus

func (job *Job) ChangeStatus(stat Status)

func (*Job) Render

func (job *Job) Render(w io.Writer) (err error)

func (*Job) Status

func (job *Job) Status() Status

func (*Job) StatusChan

func (job *Job) StatusChan() <-chan Status

type Manager

type Manager struct {
	Storage Storage
	// contains filtered or unexported fields
}

Manager maintains a render job queue and records completed jobs.

func NewManager

func NewManager(storage Storage, queueSize int) (manager *Manager)

NewManager creates a new, initialized job manager.

func (*Manager) Get

func (manager *Manager) Get(name string) (j *Job, ok bool)

Get returns a job with the given name.

func (*Manager) Init

func (manager *Manager) Init(queueSize int)

Init initializes the manager. This function is called automatically by NewJobManager.

func (*Manager) List

func (manager *Manager) List() (jobs []*Job)

func (*Manager) New

func (manager *Manager) New(yaml io.Reader, params yamlscene.Params) (j *Job, err error)

New creates a new job and adds it to the job queue.

func (*Manager) RenderJobs

func (manager *Manager) RenderJobs()

RenderJobs renders jobs in the queue until Stop is called.

func (*Manager) Stop

func (manager *Manager) Stop()

Stop causes the manager to stop accepting new jobs.

type Status

type Status struct {
	Code  StatusCode
	Error error

	ReadTime   time.Duration
	UpdateTime time.Duration
	RenderTime time.Duration
	WriteTime  time.Duration
}

func (Status) Finished

func (status Status) Finished() bool

func (Status) Started

func (status Status) Started() bool

func (Status) String

func (status Status) String() string

func (Status) TotalTime

func (status Status) TotalTime() time.Duration

type StatusCode

type StatusCode int

func (StatusCode) Finished

func (code StatusCode) Finished() bool

func (StatusCode) GoString

func (code StatusCode) GoString() string

func (StatusCode) Started

func (code StatusCode) Started() bool

func (StatusCode) String

func (code StatusCode) String() string

type Storage

type Storage interface {
	OpenReader(job *Job) (rc io.ReadCloser, err error)
	OpenWriter(job *Job) (wc io.WriteCloser, err error)
}

Storage defines an interface for a manager to store and retrieve render job results.

func NewFileStorage

func NewFileStorage(rootDir string) (Storage, error)

NewFileStorage creates a Storage based on a root directory.

Jump to

Keyboard shortcuts

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