joule

package module
v0.0.0-...-ffab533 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 2 Imported by: 0

README

Build Status

joule

Getting Started

From example/main.go:

workerFn := func(payload interface{}) error {
    v := payload.(int)
    log.Printf("%d * 2 = %d\n", v, v*2)

    // Fake some work.
    time.Sleep(time.Second * time.Duration(rand.Intn(3)))

    return nil
}

pool := joule.NewPool(workerFn, nil, 0, 0)
pool.Start(2)

for i := 1; i <= 10; i++ {
    pool.Enqueue(i)
}

pool.Stop()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorFunc

type ErrorFunc func(payload interface{}, err error)

type Pool

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

func NewPool

func NewPool(workerFn WorkerFunc, errorFn ErrorFunc, nRetries, retryDelay int) *Pool

func (*Pool) Enqueue

func (p *Pool) Enqueue(payload interface{})

func (*Pool) Start

func (p *Pool) Start(nWorkers int)

func (*Pool) Stop

func (p *Pool) Stop()

type WorkerFunc

type WorkerFunc func(payload interface{}) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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