call

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// AttemptsPosition in Args
	AttemptsPosition = 1

	// ConcurrentAttemptsPosition in Args
	ConcurrentAttemptsPosition = 2
)

Variables

View Source
var (
	// ErrInvalidArgumentsNumber is an error when the number of arguments are invalid
	ErrInvalidArgumentsNumber = errors.New("invalid number of arguments")

	// ErrMethodNotAllowed is an error with bad config method
	ErrMethodNotAllowed = errors.New("Method not allowed")

	// ErrEmptyName is an error with bad Config method
	ErrEmptyName = errors.New("Request Config name cannot be nil")
)

Functions

func ParseIntArgument

func ParseIntArgument(args []string, position int, defaultValue int) (val int, err error)

ParseIntArgument tries to parse an int argument. If it wasn't possible, returns default value

func PrintResults

func PrintResults(result Result)

PrintResults output results accord to spec in github.com/pedrolopesme/call-it/issues/6

Types

type Call

type Call interface {
	MakeIt() map[int]int
}

A Call should know how to execute itself, generating a Result from its execution

type ConcurrentCall

type ConcurrentCall struct {
	URL *url.URL // The endpoint to be tested

	Attempts           int // number of Attempts
	ConcurrentAttempts int // number of concurrent Attempts
	// contains filtered or unexported fields
}

A ConcurrentCall represents the very basic structure to start calling some URL out. It carries all data needed to call-it operate on.

func BuildCall

func BuildCall(args []string, maxAttempts, maxConcurrentAttempts int) (call ConcurrentCall, err error)

BuildCall parses all given arguments and transform them into a ConcurrentCall

func BuildCallsFromConfig

func BuildCallsFromConfig() (calls []ConcurrentCall, err error)

BuildCallsFromConfig parses a Config file and transforms the instructions into a list of ConcurrentCalls

func (*ConcurrentCall) MakeIt

func (call *ConcurrentCall) MakeIt() (result Result)

MakeIt executes a call and return its results

type Config

type Config struct {
	Name               string              `json:"name,omitempty"`
	Func               string              `json:"func,omitempty"`
	Method             string              `json:"method"`
	Attempts           int                 `json:"attempts,omitempty"`
	ConcurrentAttempts int                 `json:"concurrent,omitempty"`
	URL                string              `json:"url"`
	Body               string              `json:"body,omitempty"`
	Header             map[string][]string `json:"header,omitempty"`
	Host               string              `json:"host"`
	Form               string              `json:"form,omitempty"`
	PostForm           map[string][]string `json:"postform,omitempty"`
}

Config is the structure that defines how the user should define the config.json file to make custom requests

type HTTPResponse

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

HTTPResponse status code and execution time

type Result

type Result struct {
	URL *url.URL // Endpoint tested
	// contains filtered or unexported fields
}

A Result contains the info to be outputted at the end of the operation

type StatusCodeBenchmark

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

StatusCodeBenchmark with total of occurrences, execution time

Jump to

Keyboard shortcuts

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