worker

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 3 Imported by: 0

README

Go Worker Last release

Go Report Card

Branch Status Coverage
master Build Status Coveralls
develop Build Status Coveralls

Pool Worker fo Golang

Example

import (
    "fmt"

    "github.com/euskadi31/go-worker"
)

pool := worker.New(10, 100, func(payload interface{}) {
    val := payload.(int)

    fmt.Printf("Val: %d", val * val)
})

pool.Start()

pool.Enqueue(1)

pool.Close()

License

go-worker is licensed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPoolClosed = errors.New("pool is closed")
)

Errors messages

Functions

This section is empty.

Types

type Handler

type Handler func(payload interface{})

Handler of worker

type Pool

type Pool interface {
	WorkerSize() int
	QueueSize() int
	QueueLength() int
	Start()
	Enqueue(payload interface{}) error
	Close()
}

Pool interface

func New

func New(workerSize int, queueSize int, handler Handler) Pool

New pool worker

Jump to

Keyboard shortcuts

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