pipeline

package module
v0.0.0-...-ea3c94a Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPipeline

func NewPipeline(ctx context.Context, numEncoders, numPrinters int) (chan string, chan string)

NewPipeline initializes the workers and connects them, it returns the input of the pipeline and the final output

Types

type Job

type Job string

Job is a job a worker can do

const (
	// Print echo's all input to
	// stdout
	Print Job = "print"
	// Encode base64 encodes input
	Encode Job = "encode"
)

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker have one role that is determined when Work is called

func (*Worker) Encode

func (w *Worker) Encode(ctx context.Context)

Encode takes plain text as int and returns "string => <base64 string encoding> as out

func (*Worker) Print

func (w *Worker) Print(ctx context.Context)

Print prints w.in and repalys it on w.out

func (*Worker) Work

func (w *Worker) Work(ctx context.Context, j Job)

Work is how to dispatch a worker, they are assigned a job here

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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