fetcher

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher is an implementation of an eager content fetcher.

func New

func New(
	baseURL *url.URL,
	encoding *charmap.Charmap,
	opts ...Option,
) (*Fetcher, error)

New returns a pointer to the new instance of Fetcher or an error.

func (*Fetcher) Fetch

func (f *Fetcher) Fetch(ctx context.Context, path string) (string, error)

Fetch sends a GET-request under a relative path and returns the content as a string or returns an error.

func (Fetcher) Validate

func (f Fetcher) Validate() error

Validate validates a Fetcher and returns an error if validation is failed.

type Option

type Option func(*Fetcher)

Option set optional parameters for the Fetcher.

func WithClient

func WithClient(client httpClient) Option

WithClient sets the http client for the Fetcher.

func WithRetry

func WithRetry(cfg *RetryConfig) Option

WithRetry sets the retry configuration for the Fetcher.

type RetryConfig

type RetryConfig struct {
	Attempts          int
	MinInterval       time.Duration
	MaxInterval       time.Duration
	Factor            time.Duration
	MaxJitterInterval time.Duration
}

RetryConfig is the retry configuration for Fetcher.

func (RetryConfig) Validate

func (cfg RetryConfig) Validate() error

Validate validates a RetryConfig and returns an error if validation is failed.

Jump to

Keyboard shortcuts

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