worker

package
v0.0.0-...-7bc4285 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2021 License: MPL-2.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvailablePrinters = make(map[string]Info)

AvailablePrinters is the global variable that contains all the workers printers that have registered themselves as available.

View Source
var AvailableWorkers = make(map[string]Info)

AvailableWorkers is the global variable that contains all the workers that have registered themselves as available.

Functions

func RegisterPrinter

func RegisterPrinter(name string, info Info)

RegisterPrinter is called by each worker in order to register itself as available.

func RegisterWorker

func RegisterWorker(name string, info Info)

RegisterWorker is called by each worker in order to register itself as available.

func RemoveWorker

func RemoveWorker(name string)

RemoveWorker is called in case any worker needs to make itself unavailable ( due to unrecoverable errors ).

Types

type HasAnalysisPrinter

type HasAnalysisPrinter interface {
	AnalysisPrinter([]byte, interface{}) ([]string, error)
}

type HasAssertor

type HasAssertor interface {
	Assertor([]byte, []byte) (bool, []byte, error)
}

type Info

type Info struct {
	Runner      Worker
	Description string
}

Info represents the information that every worker gives about itself at the time of registration. Runner is the "object" on which the run method is going to be called.

type Input

type Input struct {
	Target           string
	Certificate      certificate.Certificate
	CertificateChain *certificate.Chain
	Connection       connection.Stored
	Scanid           int64
	DBHandle         *database.DB
	Params           interface{}
}

Input holds all the info that is given as input to each scanner.

type Result

type Result struct {
	Success    bool     `json:"success"`
	WorkerName string   `json:"name"`
	Result     []byte   `json:"result"`
	Errors     []string `json:"errors"`
}

Result contains all the info each worker can provide as a result, through the result channel, to the caller.

type Worker

type Worker interface {
	Run(Input, chan Result)
}

Worker is the interface that is used to provide transparent running of any type of worker from the main application.

Jump to

Keyboard shortcuts

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