assay

package
v0.0.0-...-1259547 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

View Source
const (
	//
	LogLevelNone    = 0
	LogLevelEgress  = 1
	LogLevelIngress = 2
	LogLevelDebug   = 3
)

Log Level constants, use with Logging config

  • Level 0: disable debug logging (default)
  • Level 1: log only egress traffic
  • Level 2: log only ingress traffic
  • Level 3: log full content of packets

Variables

This section is empty.

Functions

func Env

func Env(key, defaultValue string) string

Env returns value of environment variable. It is a convenient wrapper over os.LookupEnv

func Host

func Host(defaultValue string) *url.URL

Host deducts a target host from build environments. It either uses BUILD_ENDPOINT variable to read the value or casual composition ${BUILD_ID} and ${CONFIG_ENDPOINT}

Types

type Arrow

type Arrow func(*IOCat) *IOCat

Arrow is a morphism applied to IO category. The library supports various protocols through definitions of morphisms

func Join

func Join(arrows ...Arrow) Arrow

Join composes arrows to high-order function (a ⟼ b, b ⟼ c, c ⟼ d) ⤇ a ⟼ d

func (Arrow) Then

func (head Arrow) Then(arrows ...Arrow) Arrow

Then is an alias for Join

type Config

type Config func(*IOCat) *IOCat

Config defines configuration for the IO category

func Logging

func Logging(level int) Config

Logging enables debug logging of IO traffic

func SideEffect

func SideEffect(arrow Arrow) Config

SideEffect defines "unsafe" behavior for category

type DnStreamHTTP

type DnStreamHTTP struct {
	*http.Response
	Payload interface{}
}

DnStreamHTTP specify parameters for HTTP response

type IOCat

type IOCat struct {
	Fail     error
	HTTP     *IOCatHTTP
	LogLevel int
	// contains filtered or unexported fields
}

IOCat defines the category for abstract I/O with a side-effects

func IO

func IO(opts ...Config) *IOCat

IO creates the instance of I/O category use Config type to parametrize the behavior. The returned value is used to evaluate program.

func (*IOCat) Recover

func (cat *IOCat) Recover() (err error)

Recover any fail state of I/O category

func (*IOCat) Unsafe

func (cat *IOCat) Unsafe() *IOCat

Unsafe applies a side effect on the category

type IOCatHTTP

type IOCatHTTP struct {
	Send *UpStreamHTTP
	Recv *DnStreamHTTP
}

IOCatHTTP defines the category of HTTP I/O

type Mismatch

type Mismatch struct {
	Diff    string
	Payload interface{}
}

Mismatch is returned by api if expectation at body value is failed

func (*Mismatch) Error

func (e *Mismatch) Error() string

type NotSupported

type NotSupported struct{ URL *url.URL }

NotSupported is returned if communication schema is not supported.

func (*NotSupported) Error

func (e *NotSupported) Error() string

type Ord

type Ord interface {
	sort.Interface
	// String return primary key as string type
	String(int) string
	// Value return value at index
	Value(int) interface{}
}

Ord extends sort.Interface with ability to lookup element by string. This interface is a helper abstraction to evaluate presence of element in the sequence.

assay.Join(
  ...
  ç.Seq(&seq).Has("example"),
  ...
)

The example above shows a typical usage of Ord interface. The remote peer returns sequence of elements. The lens Seq and Has focuses on the required element. A reference implementation of the interface is

type Seq []MyType

func (seq Seq) Len() int                { return len(seq) }
func (seq Seq) Swap(i, j int)           { seq[i], seq[j] = seq[j], seq[i] }
func (seq Seq) Less(i, j int) bool      { return seq[i].MyKey < seq[j].MyKey }
func (seq Seq) String(i int) string     { return seq[i].MyKey }
func (seq Seq) Value(i int) interface{} { return seq[i] }

type Undefined

type Undefined struct {
	Type string
}

Undefined is returned by api if expectation at body value is failed

func (*Undefined) Error

func (e *Undefined) Error() string

type UpStreamHTTP

type UpStreamHTTP struct {
	Method  string
	URL     *url.URL
	Header  map[string]*string
	Payload io.Reader
}

UpStreamHTTP specify parameters for HTTP requests

Jump to

Keyboard shortcuts

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