pool

package
v0.0.0-...-b631e0d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Hash is the bcrypt work type
	Hash op = "encrypt"
	// Compare is bcrypt compare work
	Compare = "decrypt"
)

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(numWorker int) (context.CancelFunc, chan WorkRequest, chan WorkResponse)

Dispatch creates numWorker workers, returns a cancel functionand channels for adding work and responses, cancel must be called

func Worker

func Worker(ctx context.Context, id int, in chan WorkRequest, out chan WorkResponse)

Worker loops forever and is part of the worker pool

Types

type WorkRequest

type WorkRequest struct {
	Op      op
	Text    []byte
	Compare []byte // optional
}

WorkRequest is a worker req

type WorkResponse

type WorkResponse struct {
	Wr      WorkRequest
	Result  []byte
	Matched bool
	Err     error
}

WorkResponse is a worker resp

func Process

func Process(wr WorkRequest) WorkResponse

Process dispatches work to the worker pool channel

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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