api

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNoAPIName     = errors.New("API name is required")
	ErrorNoAPIMakeFunc = errors.New("no endpoint make function is specified")
)

Functions

func SetDefaultAPIBreakerFlagsPrefix

func SetDefaultAPIBreakerFlagsPrefix(prefix string)

func SetDefaultAPIBreakerInterval

func SetDefaultAPIBreakerInterval(val time.Duration)

func SetDefaultAPIBreakerMaxRequests

func SetDefaultAPIBreakerMaxRequests(val uint32)

func SetDefaultAPIBreakerTimeout

func SetDefaultAPIBreakerTimeout(val time.Duration)

func SetDefaultAPIFlagsPrefix

func SetDefaultAPIFlagsPrefix(prefix string)

func SetDefaultAPILogKVs

func SetDefaultAPILogKVs(logkvs map[string]string)

func SetDefaultAPIRateLimitDelta

func SetDefaultAPIRateLimitDelta(val int)

func SetDefaultAPIRateLimitDuration

func SetDefaultAPIRateLimitDuration(val time.Duration)

func SetDefaultAPIRateLimitFlagsPrefix

func SetDefaultAPIRateLimitFlagsPrefix(prefix string)

Types

type API

type API struct {
	Name       string            `json:"name" yaml:"name"`
	LogKVs     map[string]string `json:"log" yaml:"log"`
	Instrument []string          `json:"instrument" yaml:"instrument"`
	RateLimit  RateLimit         `json:"ratelimit" yaml:"ratelimit"`
	Breaker    Breaker           `json:"breaker" yaml:"breaker"`

	Path   string `json:"path" yaml:"path"`
	Method string `json:"method" yaml:"method"`

	// CustomBindFlagsFunc defines custom bind flags behaviour for structure, if CustomBindFlagsFunc is nil, default  bind flags behaviour will be used
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`

	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

func (*API) BindFlags

func (a *API) BindFlags(fs *bootflag.FlagSet)

func (API) GetGoKitLoggerKVs

func (a API) GetGoKitLoggerKVs() (kvs []interface{})

func (*API) Parse

func (a *API) Parse() (err error)

type APIs

type APIs map[string]API

func (*APIs) Parse

func (as *APIs) Parse() (err error)

type Breaker

type Breaker struct {
	Name                string                     `json:"name" yaml:"name"`
	MaxRequests         uint32                     `json:"max" yaml:"max"`
	Interval            time.Duration              `json:"interval" yaml:"interval"`
	Timeout             time.Duration              `json:"timeout" yaml:"timeout"`
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`
	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

func (*Breaker) BindFlags

func (b *Breaker) BindFlags(fs *bootflag.FlagSet)

func (*Breaker) Parse

func (b *Breaker) Parse() (err error)

func (*Breaker) Standardize

func (b *Breaker) Standardize() gobreaker.Settings

type Method

type Method uint8
const (
	GET Method = iota
	POST
	DELETE
	PUT
	PATCH
)

type RateLimit

type RateLimit struct {
	Delta               int                        `json:"delta" yaml:"delta"`
	Duration            time.Duration              `json:"duration" yaml:"duration"`
	CustomBindFlagsFunc func(fs *bootflag.FlagSet) `json:"-" yaml:"-"`
	// CustomParseFunc defines custom parse behaviour for structure, if CustomParseFunc is nil, default parse behaviour will be used
	CustomParseFunc func() (err error) `json:"-" yaml:"-"`
}

func (*RateLimit) BindFlags

func (rl *RateLimit) BindFlags(fs *bootflag.FlagSet)

func (RateLimit) Parse

func (rl RateLimit) Parse() (err error)

Jump to

Keyboard shortcuts

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