helper

package
v0.0.0-...-d4e64a4 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalServer = &model.Error{500, "Internal Server Error", "Something went wrong."}
	ErrBadRequest     = &model.Error{400, "Bad Request", "The request had bad syntax or was inherently impossible to be satisfied"}
	ErrUnauthorized   = &model.Error{401, "Unauthorized", "Login required"}
	ErrForbidden      = &model.Error{403, "Forbidden", "Access deny"}
	ErrNotFound       = &model.Error{404, "Not Found", "Not found anything matching the URI given"}
	ErrMethodNotFound = &model.Error{405, "Method Not Found", "Not found anything matching method"}
)
View Source
var Cache *cache.Cache
View Source
var WorkQueue = make(chan model.ScanRequest, 100)
View Source
var WorkerQueue chan chan model.ScanRequest

Functions

func AddError

func AddError(c *gin.Context, e *model.Error)

func GetErrors

func GetErrors(c *gin.Context) *model.Errors

func GetScanRequest

func GetScanRequest(id string) (*model.ScanRequest, error)

func GitScan

func GitScan(req *model.ScanRequest) (*model.ScanRequest, error)

func SetErrors

func SetErrors(c *gin.Context)

func StartDispatcher

func StartDispatcher(nworkers int)

Types

type Worker

type Worker struct {
	Id          int
	Work        chan model.ScanRequest
	WorkerQueue chan chan model.ScanRequest
	QuitChan    chan bool
}

func NewWorker

func NewWorker(id int, workerQueue chan chan model.ScanRequest) Worker

func (*Worker) Start

func (w *Worker) Start()

This function "starts" 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