models

package
v0.0.0-...-ec02829 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorTransactionNameMissing   = errors.New("transaction name is missing")
	ErrorTransactionChecksMissing = errors.New("transaction checks are missing")
)

Transaction Errors

View Source
var (
	ErrorCheckNameMissing       = errors.New("check name is missing")
	ErrorCheckURLMissing        = errors.New("check url is missing")
	ErrorCheckURLInvalid        = errors.New("check url is invalid")
	ErrorCheckInvalidMethod     = errors.New("check method is invalid")
	ErrorCheckAssertionsMissing = errors.New("check assertions are missing")
)

EndpointCheck Errors

View Source
var (
	ErrorNotImplemented = errors.New("not implemented")
)

General Errors

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	Name  string        `yaml:"name"`
	Type  AssertionType `yaml:"type"`
	Value string        `yaml:"value"`
}

func (*Assertion) AssertResult

func (a *Assertion) AssertResult(result *EndpointCheckResult) (success bool, err error)

type AssertionType

type AssertionType string
const (
	AssertionTypeStatusCode AssertionType = "status_code"
	AssertionTypeBody       AssertionType = "body"
)

type Config

type Config struct {
	Version      string        `yaml:"version"`
	Name         string        `yaml:"name"`
	Execute      ExecuteType   `yaml:"execute"`
	Sleep        int           `yaml:"sleep"`
	Transactions []Transaction `yaml:"transactions"`
	Outputs      []Output      `yaml:"outputs"`
}

func (*Config) Load

func (c *Config) Load(configFileReader io.Reader) error

type EndpointCheck

type EndpointCheck struct {
	Name       string            `yaml:"name"`
	URL        string            `yaml:"url"`
	Method     Method            `yaml:"method"`
	Headers    map[string]string `yaml:"headers"`
	Body       string            `yaml:"body"`
	Timeout    int               `yaml:"timeout"`
	Assertions []Assertion       `yaml:"assertions"`
}

func (*EndpointCheck) AssertResult

func (c *EndpointCheck) AssertResult(result *EndpointCheckResult) (success bool, err error)

func (*EndpointCheck) Validate

func (c *EndpointCheck) Validate() error

type EndpointCheckResult

type EndpointCheckResult struct {
	Name                 string
	StatusCode           int
	URL                  string
	Error                string
	Body                 []byte
	Headers              map[string][]string
	DNSDuration          time.Duration
	TLSHandshakeDuration time.Duration
	ConnectDuration      time.Duration
	FirstByteDuration    time.Duration
	TotalDuration        time.Duration

	// Will only be set after successfull assertion
	Success bool
}

type ExecuteType

type ExecuteType string
const (
	ExecuteTypeOnce ExecuteType = "once"
	ExecuteTypeLoop ExecuteType = "loop"
)

type Method

type Method string
const (
	MethodGet     Method = "GET"
	MethodHead    Method = "HEAD"
	MethodPost    Method = "POST"
	MethodPut     Method = "PUT"
	MethodPatch   Method = "PATCH"
	MethodDelete  Method = "DELETE"
	MethodConnect Method = "CONNECT"
	MethodOptions Method = "OPTIONS"
	MethodTrace   Method = "TRACE"
)

type Output

type Output struct {
	Type     OutputType `yaml:"type"`
	Host     string     `yaml:"host"`
	User     string     `yaml:"user"`
	Password string     `yaml:"password"`
	Database string     `yaml:"database"`
	Insecure bool       `yaml:"insecure"`
}

type OutputType

type OutputType string
const (
	OutputTypeStdOut   OutputType = "stdout"
	OutputTypeInfluxDB OutputType = "influxdb"
)

type Result

type Result struct {
	Name               string
	TransactionResults []TransactionResult
}

type Transaction

type Transaction struct {
	Name   string          `yaml:"name"`
	Checks []EndpointCheck `yaml:"checks"`
}

func (*Transaction) Validate

func (t *Transaction) Validate() error

type TransactionResult

type TransactionResult struct {
	Name                 string
	Success              bool
	EndpointCheckResults []EndpointCheckResult
}

Jump to

Keyboard shortcuts

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