sender

package
v0.0.0-...-d386c04 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Trace:   false,
	Timeout: 5000,
	Retry: Retry{
		Count:    3,
		WaitTime: 100,
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Trace   bool              `json:"trace" yaml:"trace" mapstructure:"trace"`
	Timeout int               `json:"timeout" yaml:"timeout" mapstructure:"timeout"`
	Retry   Retry             `json:"retry" yaml:"retry" mapstructure:"retry"`
	Headers map[string]string `json:"header" yaml:"header" mapstructure:"header"`
}

func (*Config) Validate

func (conf *Config) Validate() error

type Request

type Request struct {
	Method  string      `json:"method"`
	Headers http.Header `json:"headers"`
	Uri     string      `json:"uri"`
	Body    []byte      `json:"body"`
}

type Response

type Response struct {
	Status  int         `json:"status"`
	Headers http.Header `json:"headers"`
	Uri     string      `json:"uri"`
	Body    []byte      `json:"body"`
}

type RestError

type RestError struct {
	Status  string
	Headers http.Header
	Uri     string
	Body    []byte
}

func (*RestError) Error

func (err *RestError) Error() string

type Retry

type Retry struct {
	Count    int `json:"count" yaml:"count" mapstructure:"count"`
	WaitTime int `json:"wait_time" yaml:"wait_time" mapstructure:"wait_time"`
}

func (*Retry) Validate

func (conf *Retry) Validate() error

type Send

type Send func(context.Context, *Request) (*Response, error)

func New

func New(conf *Config, logger logging.Logger) (Send, error)

func Rest

func Rest(conf *Config, logger logging.Logger) Send

type Sender

type Sender func(conf *Config) Send

Jump to

Keyboard shortcuts

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