gallery

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2017 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// WorkerQueue channel controller
	WorkerQueue chan chan Image
	// WorkQueue channel
	WorkQueue chan Image
	// WorkerStop quit channel
	WorkerStop chan bool
)
View Source
var ImageDir string

ImageDir is where you keep your images. Needs write permissions on `thumbs` subdirectory

Functions

func StartDispatcher

func StartDispatcher(nworkers int)

StartDispatcher creates nworkers and distributes incoming work to them

func StopDispatcher

func StopDispatcher()

StopDispatcher blocks until all workers have finished and queues are closed

Types

type Image

type Image struct {
	ID    int
	Src   string
	Thumb string
	Valid bool
}

Image type

type ImageCache

type ImageCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ImageCache threadsafe cache

var Images ImageCache

Images global, stores a cache of gallery entries and if they have valid thumbnails or not

func (*ImageCache) List

func (c *ImageCache) List() []Image

List provides a copy of the cache

func (*ImageCache) Set

func (c *ImageCache) Set(id int, img Image)

Set the value of a gallery entry

func (*ImageCache) Update

func (c *ImageCache) Update() error

Update will rescan the directory for any files that don't have a thumbnail and attempt to generate one

type WorkRequest

type WorkRequest struct {
	Src   string
	Thumb string
}

WorkRequest to be exported to json

type Worker

type Worker struct {
	ID          int
	Work        chan Image
	WorkerQueue chan chan Image
	QuitChan    chan bool
}

Worker type

func NewWorker

func NewWorker(id int, workerQueue chan chan Image) Worker

NewWorker creates, and returns a new Worker object. Its only argument is a channel that the worker can add itself to whenever it is done its work.

func (*Worker) Start

func (w *Worker) Start()

Start the worker by starting a goroutine, that is an infinite "for-select" loop.

func (*Worker) Stop

func (w *Worker) Stop()

Stop tells the worker to stop listening for work requests. Note that the worker will only stop *after* it has finished its work.

Jump to

Keyboard shortcuts

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