client

package
v0.0.0-...-ba7165a Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const AuthSchemeBasic = "basic"

AuthSchemeBasic is used as the authentication method description.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertificateDecodeError

type CertificateDecodeError struct{}

func (*CertificateDecodeError) Error

func (e *CertificateDecodeError) Error() string

type CertificateReadError

type CertificateReadError struct {
	Err error
}

func (*CertificateReadError) Error

func (e *CertificateReadError) Error() string

func (*CertificateReadError) Unwrap

func (e *CertificateReadError) Unwrap() error

type Client

type Client struct {
	Workers []*Worker
	// contains filtered or unexported fields
}

Client is a instructor client.

func NewClient

func NewClient() *Client

NewClient returns a new client.

func (*Client) AddWorker

func (c *Client) AddWorker(
	adress string,
	port int,
	secret string,
	cert *tls.Certificate,
	dialer func(context.Context, string) (net.Conn, error)) error

AddWorker adds a new worker to the client. A worker is defined by it's connection attributes, which are it's ip address, port, a token secret, a TLS certificate, and an optional dialer function, which mainly serves for testing purposes.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, logger *zerolog.Logger) error

Connect opens a connection to every worker added to this client. It closes existing connections first, then creates a new one.

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect closes connections to all workers belonging to this client.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context, logger *zerolog.Logger) error

Ping serially pings every Worker.

func (*Client) Run

func (c *Client) Run(
	ctx context.Context,
	logger *zerolog.Logger,
	endpoints []*config.InstructorEndpoint,
	amount, minWaitTime, maxWaitTime int) (chan Result, error)

Run requests every worker to perform a loadtest. It returns an error on failure to initialize the requests, otherwise it returns a channel in which the results will be written, but returns immediately.

logger will be used to log messages mid-process, endpoints are the endpoints which workers will target to, amount specifies the amount of users each worker simulates, minWaitTime and maxWaitTime specify the time to wait between requests in milliseconds.

To cancel requesting the workers, ctx has to be canceled.

type ConnectError

type ConnectError struct {
	Err error
}

func (*ConnectError) Error

func (e *ConnectError) Error() string

func (*ConnectError) Unwrap

func (e *ConnectError) Unwrap() error

type DisconnectError

type DisconnectError struct {
	Err error
}

func (*DisconnectError) Error

func (e *DisconnectError) Error() string

func (*DisconnectError) Unwrap

func (e *DisconnectError) Unwrap() error

type InvalidConnectionError

type InvalidConnectionError struct {
	Err error
}

func (*InvalidConnectionError) Error

func (e *InvalidConnectionError) Error() string

func (*InvalidConnectionError) Unwrap

func (e *InvalidConnectionError) Unwrap() error

type Result

type Result struct {
	URL               *url.URL
	HttpStatusCode    int
	HttpStatusMessage string
	Ttfb              time.Duration
	Cached            bool
}

type Worker

type Worker struct {
	Adress      string
	Port        int
	Certificate *tls.Certificate
	Secret      string
	// contains filtered or unexported fields
}

Worker represents the configuration and connection of a Worker.

func (*Worker) String

func (w *Worker) String() string

type WrappableError

type WrappableError interface {
	error
	Unwrap() error
}

Jump to

Keyboard shortcuts

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