sender

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

sender provides async http(s) egress functionality over a channel. The code follows a

[driver] -> [channel] -> [worker(s)]

pattern that is common in Go. Requests are sent over a channel and response body is currently ignored. Each worker will wait for http request to finish. Caller is expected to create multiple worker independently for throughput. One worker will only have one outstanding http request. Parallelism is controlled entirely by how many workers are created by the caller. TODO: track and record request status by X-Request-ID

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Worker)

Option controlls a set of options that can be set on Worker This is to make it convenient to control settings without the New method taking tens of arguments

func Dryrun

func Dryrun(dryRun bool) Option

func ExitOnFirstError

func ExitOnFirstError(exitOnFirstError bool) Option

func ExtractToFile

func ExtractToFile(extractToFile bool) Option

func MatchReqID

func MatchReqID(reqID string) Option

func MinDelayMS

func MinDelayMS(minDelayMs int) Option

func OutputDirectory

func OutputDirectory(outputDir string) Option

func Quiet

func Quiet(quiet bool) Option

type Worker

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

func NewWorker

func NewWorker(reqChan chan *request.UnmarshalledRequest, errorRespChan chan bool, targetHost string, wg *sync.WaitGroup, grID int) (wrk *Worker)

NewWorker creates a new instance of an 'http egress worker' with a few datastructures it keeps track of. Please note that NewWorker does not start a thread or go-routine, caller must call `go worker.Run()` when all options have been set and it ready to start the job. Job details are consumed over a channel, `reqChan`, created by the caller and a given worker will process an unlimited number of tasks. Caller must close the `reqChan` to indicate end of job. Caller must also listen to (and consume) `errorRespChan` for errors If caller does not consume errorRespChan, deadlocks will occur.

func (*Worker) Run

func (wrk *Worker) Run()

func (*Worker) WithOption

func (wrk *Worker) WithOption(opts ...Option)

Jump to

Keyboard shortcuts

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