process

package
v0.0.0-...-e9fe98c Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2019 License: MIT Imports: 23 Imported by: 2

Documentation

Overview

Package process is a package for managing a processing pipeline. Copied from https://github.com/rheinardkorf/go-concurrency/blob/master/11_pipeline_complex/pipe/process.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	Process                  // Inherits methods from Process.
	In      <-chan Processor // Expects a processor channel as input.
	Out     chan Processor   // Send results to an output channel.
}

Info defines the structure for our Info process.

func (*Info) Do

func (info *Info) Do() error

Do runs the actual code for this process.

func (*Info) Run

func (info *Info) Run(errc *chan error) error

Run executes the process in the pipeline.

type Ingest

type Ingest struct {
	Process                           // Inherits methods from Process.
	In         <-chan message.Message // Expects a message channel as input.
	Out        chan Processor         // Send results to an output channel.
	TempFolder string                 // Path to a temp folder where files will be extracted.
	// contains filtered or unexported fields
}

Ingest defines the structure for our Ingest process.

func (*Ingest) Do

func (ig *Ingest) Do() error

Do runs the actual code for this process.

func (*Ingest) Run

func (ig *Ingest) Run(errc *chan error) error

Run executes the process in the pipeline.

type Lighthouse

type Lighthouse struct {
	Process                          // Inherits methods from Process.
	In              <-chan Processor // Expects a processor channel as input.
	Out             chan Processor   // Send results to an output channel.
	TempFolder      string           // Path to a temp folder where reports will be generated.
	StorageProvider storage.Provider // Storage provider to upload reports to.
}

Lighthouse defines the structure for our Lighthouse process.

func (*Lighthouse) Do

func (lh *Lighthouse) Do() error

Do executes the process.

func (*Lighthouse) Run

func (lh *Lighthouse) Run(errc *chan error) error

Run runs the process in a pipeline.

type Phpcs

type Phpcs struct {
	Process                                      // Inherits methods from Process.
	In              <-chan Processor             // Expects a processor channel as input.
	Out             chan Processor               // Send results to an output channel.
	Config          Result                       // Additional config.
	TempFolder      string                       // Path to a temp folder where reports will be generated.
	StorageProvider storage.Provider             // Storage provider to upload reports to.
	PhpcsVersions   map[string]map[string]string // PHPCS versions.
}

Phpcs defines the structure for our Phpcs process.

func (*Phpcs) Do

func (cs *Phpcs) Do() error

Do executes the process.

func (*Phpcs) Run

func (cs *Phpcs) Run(errc *chan error) error

Run executes the process in a pipe.

type Process

type Process struct {
	Message   message.Message // Keeps track of the original message.
	Result    *Result         // Passes along a Result object.
	FilesPath string          // Path of files to audit.
	// contains filtered or unexported fields
}

Process is the base for all processes.

func (*Process) CopyFields

func (p *Process) CopyFields(proc Processor)

CopyFields copies required fields from one process to another.

func (Process) Error

func (p Process) Error(msg string) error

Error returns a new process error.

func (Process) GetFilesPath

func (p Process) GetFilesPath() string

GetFilesPath gets the path of the source used for processing.

func (Process) GetMessage

func (p Process) GetMessage() message.Message

GetMessage returns the message object for this process.

func (Process) GetResult

func (p Process) GetResult() *Result

GetResult gets the results attached to this process.

func (*Process) Run

func (p *Process) Run() (<-chan error, error)

Run is a default implementation with an error nag. Not required, but serves as an example.

func (*Process) SetContext

func (p *Process) SetContext(ctx context.Context)

SetContext sets the context so that it can be used in the processes to terminate goroutines if it needs to.

func (*Process) SetFilesPath

func (p *Process) SetFilesPath(path string)

SetFilesPath sets the path of the code to run the process againsts.

func (*Process) SetMessage

func (p *Process) SetMessage(msg message.Message)

SetMessage is used to set the Message for this process (used for copying the message).

func (*Process) SetResults

func (p *Process) SetResults(res *Result)

SetResults sets the results for this process (used for copying results from process to process).

type Processor

type Processor interface {
	Run(*chan error) error
	Do() error
	SetContext(ctx context.Context)
	SetMessage(msg message.Message)
	GetMessage() message.Message
	SetResults(res *Result)
	GetResult() *Result
	SetFilesPath(path string)
	GetFilesPath() string
}

Processor is an interface for all processors.

type Response

type Response struct {
	Process                                 // Inherits methods from Process.
	In         <-chan Processor             // Expects a processor channel as input.
	Out        chan Processor               // (Optional) Send results to an output channel.
	Payloaders map[string]payload.Payloader // A map of "Payloader"s for different services.
}

Response defines the structure for a Response process. This determines where the processed results will be sent.

func (*Response) Do

func (res *Response) Do() error

Do executes the process.

func (*Response) Run

func (res *Response) Run(errc *chan error) error

Run executes the process in a pipe.

type Result

type Result map[string]interface{}

Result is an interface map of the processed results.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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