resources

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package resources contains code to download resources.

Index

Constants

View Source
const (
	// ASNDatabaseName is the name of the ASN database file
	ASNDatabaseName = "asn.mmdb"

	// CABundleName is the name of the CA bundle file
	CABundleName = "ca-bundle.pem"

	// CountryDatabaseName is the name of the country database file
	CountryDatabaseName = "country.mmdb"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// HTTPClient is the HTTP client to use.
	HTTPClient *http.Client

	// Logger is the logger to use.
	Logger log.Logger

	// UserAgent is the user agent to use.
	UserAgent string

	// WorkDir is the directory where to save resources.
	WorkDir string
}

Client is a client for fetching resources.

func (*Client) Ensure

func (c *Client) Ensure(ctx context.Context) error

Ensure ensures that resources are downloaded and current.

func (*Client) EnsureForSingleResource

func (c *Client) EnsureForSingleResource(
	ctx context.Context, name string, resource ResourceInfo,
	equal func(real, expected string) bool,
	gzipNewReader func(r io.Reader) (*gzip.Reader, error),
	ioutilReadAll func(r io.Reader) ([]byte, error),
) error

EnsureForSingleResource ensures that a single resource is downloaded and is current.

type ResourceInfo

type ResourceInfo struct {
	URLPath  string
	GzSHA256 string
	SHA256   string
}

ResourceInfo contains information on a resource.

Jump to

Keyboard shortcuts

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