decorator

package
v0.0.0-...-8b849f6 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Debug       *log.Logger
	Info        *log.Logger
	Error       *log.Logger
	InfoHandler io.Writer
)

Functions

func InitLog

func InitLog(
	traceFileName string,
	debugHandler io.Writer,
	infoHandler io.Writer,
	errorHandler io.Writer,
)

Types

type Client

type Client interface {
	Do(*http.Request) (*http.Response, error)
}

func Decorate

func Decorate(c Client, ds ...Decorator) Client

type ClientFunc

type ClientFunc func(*http.Request) (*http.Response, error)

func (ClientFunc) Do

func (f ClientFunc) Do(r *http.Request) (*http.Response, error)

func (ClientFunc) GetRatelimit

func (f ClientFunc) GetRatelimit() (time.Duration, error)

func (ClientFunc) SetRatelimit

func (f ClientFunc) SetRatelimit(duration time.Duration) error

type Decorator

type Decorator func(Client) Client

func Authorization

func Authorization(token string) Decorator

func FaultTolerance

func FaultTolerance(attempts int, backoff time.Duration) Decorator

FaultTolerance returns a Decorator that extends a Client with fault tolerance configured with the given attempts and backoff duration

func Header(name, value string) Decorator

func LoadBalancing

func LoadBalancing(dir Director) Decorator

func Logging

func Logging(l *log.Logger) Decorator

type Director

type Director func(*http.Request)

func RoundRobin

func RoundRobin(robin int64, backends ...string) Director

type Job

type Job struct {
	Client       Client
	NumRequests  int
	Request      *http.Request
	IntervalSecs int
	// contains filtered or unexported fields
}

func (*Job) Run

func (j *Job) Run()

Jump to

Keyboard shortcuts

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