net

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package net implements a backend that communicates over a network. It uses HTTP and protocol buffers for communication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

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

Backend represents a host that accepts requests for metrics over HTTP.

func New

func New(cfg Config) (*Backend, error)

New creates a new backend from the given configuration.

func (Backend) Contains

func (b Backend) Contains(targets []string) bool

Contains reports whether the backend contains any of the given targets.

func (Backend) Find

func (b Backend) Find(ctx context.Context, request types.FindRequest) (types.Matches, error)

Find resolves globs and finds metrics in a backend.

func (Backend) Info

func (b Backend) Info(ctx context.Context, request types.InfoRequest) ([]types.Info, error)

Info fetches metadata about a metric from a backend.

func (Backend) Logger

func (b Backend) Logger() *zap.Logger

Logger returns logger for this backend. Needed to satisfy interface.

func (*Backend) Probe

func (b *Backend) Probe()

Probe performs a single update of the backend's top-level domains.

func (Backend) Render

func (b Backend) Render(ctx context.Context, request types.RenderRequest) ([]types.Metric, error)

Render fetches raw metrics from a backend.

type Config

type Config struct {
	Address string // The backend address.

	// Optional fields
	Client             *http.Client  // The client to use to communicate with backend. Defaults to http.DefaultClient.
	Timeout            time.Duration // Set request timeout. Defaults to no timeout.
	Limit              int           // Set limit of concurrent requests to backend. Defaults to no limit.
	PathCacheExpirySec uint32        // Set time in seconds before items in path cache expire. Defaults to 10 minutes.
	Logger             *zap.Logger   // Logger to use. Defaults to a no-op logger.
}

Config configures an HTTP backend.

The only required field is Address, which must be of the form "address[:port]", where address is an IP address or a hostname. Address must be a point that can accept HTTP requests.

type ErrHTTPCode

type ErrHTTPCode int

ErrHTTPCode is a custom error type to distinguish HTTP errors

func (ErrHTTPCode) Error

func (e ErrHTTPCode) Error() string

Jump to

Keyboard shortcuts

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