parallel

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConnPerHost   = 5
	DefaultParallelHosts = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	MaxConnPerHost   int
	MaxParallelHosts int
}

func New

func New() *Client

func (*Client) GetParallelHosts

func (c *Client) GetParallelHosts(targets []string) error

GetParallelHosts will retrieve each target on a separate connection This uses a simple fan-out fan-in concurrency model

func (*Client) GetPathDiffOnHost

func (c *Client) GetPathDiffOnHost(base string, targets []string, opts ...ParallelOption) error

GetPathDiffOnHost will send the targets to the base host on both a http2 and a h2c connection the results will be diffed this will use c.MaxConnPerHost to parallelize the paths This assumes that the host can be connected to over h2c. This will fail if attempted with a host that cannot be h2c smuggled TODO: minimize allocations here, since we explode out a lot

func (*Client) GetPathsOnHost

func (c *Client) GetPathsOnHost(base string, targets []string, opts ...ParallelOption) error

GetPathsOnHost will send the targets to the base host this will use c.MaxConnPerHost to parallelize the paths This assumes that the host can be connected to over h2c. This will fail if attempted with a host that cannot be h2c smuggled TODO: minimize allocations here, since we explode out a lot

type Diff

type Diff struct {
	HTTP2 *res
	H2C   *res
}

type DiffState

type DiffState struct {
	Host        string      `json:"host,omitempty"`
	SameHeaders http.Header `json:"same_headers,omitempty"`
	H2C         State       `json:"H2C"`
	Normal      State       `json:"normal"`
}

func (DiffState) Map

func (d DiffState) Map() map[string]interface{}

func (DiffState) String

func (d DiffState) String() string

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

type ParallelOption

type ParallelOption func(o *ParallelOptions)

func PrettyPrint

func PrettyPrint(v bool) ParallelOption

func RequestHeader

func RequestHeader(key string, value string) ParallelOption

func RequestMethod

func RequestMethod(method string) ParallelOption

type ParallelOptions

type ParallelOptions struct {
	RequestMutations []RequestMutation
	PrettyPrint      bool
}

type RequestMutation

type RequestMutation func(req *http.Request)

type ResponseDiff

type ResponseDiff struct {
	DeleteOnShow bool // if enabled, results will be cleared from the cache once shown
	PrettyPrint  bool // print the diff prettily
	// contains filtered or unexported fields
}

func NewDiffer

func NewDiffer(DeleteOnShow bool) *ResponseDiff

func (*ResponseDiff) ShowDiffH2C

func (r *ResponseDiff) ShowDiffH2C(http2res *res)

ShowDiffH2C will show if there's a diff between the http2 and h2c responses. if the corresponding response is not cached, this does nothing

func (*ResponseDiff) ShowDiffHTTP2

func (r *ResponseDiff) ShowDiffHTTP2(http2res *res)

ShowDiffHTTP2 will show if there's a diff between the http2 and h2c responses. if the corresponding response is not cached, this does nothing

type State

type State struct {
	StatusCode         int         `json:"status_code,omitempty"`
	ResponseBodyLength int         `json:"response_body_length,omitempty"`
	Headers            http.Header `json:"headers,omitempty"`
	Body               string      `json:"body,omitempty"`
	Error              error       `json:"error,omitempty"`
}

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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