lookup

package
v0.0.0-...-7e90556 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTooManyRequests - Trying to send too many fetch requests
	ErrTooManyRequests = errors.New("Trying to send too many fetch requests")

	// ErrExtractingValue - Failed to extract a value with given arguments
	ErrExtractingValue = errors.New("Failed to extract value with given arguments")
)

Functions

This section is empty.

Types

type BasicHTTPRequestHandler

type BasicHTTPRequestHandler struct {
	HTTPClient *http.Client
}

BasicHTTPRequestHandler is an HTTPRequestHandler that uses an http.Client.

func (*BasicHTTPRequestHandler) Get

func (h *BasicHTTPRequestHandler) Get(url string, args map[string]string) ([]byte, error)

Get sends the given args to the given url and returns the response body or an error.

type HTTPRequestHandler

type HTTPRequestHandler interface {
	Get(string, map[string]string) ([]byte, error)
}

HTTPRequestHandler is an interface to issue Get requests.

type JSONValueFetcher

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

JSONValueFetcher extracts a particular field value from a JSON obtained through a GET request

func (*JSONValueFetcher) FetchInt64

func (f *JSONValueFetcher) FetchInt64(args map[string]string) (int64, error)

FetchInt64 constructs a GET HTTP query with the provided map as URL arguments and returns the value as an int64 if possible

type JSONValueFetcherConfig

type JSONValueFetcherConfig struct {
	URL           string // URL to send the GET request
	JQ            string // JQ expression to extract a particular field from the fetched JSON
	TimeoutMS     int    // Timeout in ms for GET requests
	RatePerSecond int    // Amount of requests allowed per second
	BurstSize     int    // Maximum amount of concurrent requests possible
}

JSONValueFetcherConfig contains the required information to instantiate a JSONValueFetcher

type ValueFetcher

type ValueFetcher interface {
	FetchInt64(map[string]string) (int64, error)
}

ValueFetcher fetches values with a given set of arguments.

func NewJSONValueFetcher

func NewJSONValueFetcher(
	config JSONValueFetcherConfig,
	stats reporter.StatsLogger,
) (ValueFetcher, error)

NewJSONValueFetcher returns a ValueFetcher that uses a BasicHTTPRequestHandler wrapping a http.Client instance with the given timeout in ms to service GET requests

Jump to

Keyboard shortcuts

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