handler

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package handler provides a client and handlers for responding to locate requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Signer

	Locator
	LocatorV2
	ClientLocator
	PrometheusClient
	// contains filtered or unexported fields
}

Client contains state needed for xyz.

func NewClient

func NewClient(project string, private Signer, locator Locator, locatorV2 LocatorV2, client ClientLocator, prom PrometheusClient) *Client

NewClient creates a new client.

func NewClientDirect added in v0.4.1

func NewClientDirect(project string, private Signer, locator Locator, locatorV2 LocatorV2, client ClientLocator, prom PrometheusClient) *Client

NewClientDirect creates a new client with a target template using only the target machine.

func (*Client) Heartbeat

func (c *Client) Heartbeat(rw http.ResponseWriter, req *http.Request)

Heartbeat implements /v2/heartbeat requests. It starts a new persistent connection and a new goroutine to read incoming messages.

func (*Client) Monitoring

func (c *Client) Monitoring(rw http.ResponseWriter, req *http.Request)

Monitoring implements /v2/monitoring requests.

func (*Client) Nearest added in v0.11.0

func (c *Client) Nearest(rw http.ResponseWriter, req *http.Request)

Nearest uses an implementation of the LocatorV2 interface to look up nearest servers.

func (*Client) Prometheus added in v0.13.0

func (c *Client) Prometheus(rw http.ResponseWriter, req *http.Request)

Prometheus is a handler that collects Prometheus health signals.

func (*Client) TranslatedQuery

func (c *Client) TranslatedQuery(rw http.ResponseWriter, req *http.Request)

TranslatedQuery uses the legacy mlab-ns service for liveness as a transitional step in loading state directly.

type ClientLocator added in v0.7.0

type ClientLocator interface {
	Locate(req *http.Request) (*clientgeo.Location, error)
}

ClientLocator defines the interfeace for looking up the client geo location.

type Locator

type Locator interface {
	Nearest(ctx context.Context, service, lat, lon string) ([]v2.Target, error)
}

Locator defines how the TranslatedQuery handler requests machines nearest to the client.

type LocatorV2 added in v0.11.0

type LocatorV2 interface {
	Nearest(service string, lat, lon float64, opts *heartbeat.NearestOptions) ([]v2.Target, []url.URL, error)
	heartbeat.StatusTracker
}

LocatorV2 defines how the Nearest handler requests machines nearest to the client.

type PrometheusClient added in v0.13.0

type PrometheusClient interface {
	Query(ctx context.Context, query string, ts time.Time, opts ...prom.Option) (model.Value, prom.Warnings, error)
}

PrometheusClient defines the interface to query Prometheus.

type Signer

type Signer interface {
	Sign(cl jwt.Claims) (string, error)
}

Signer defines how access tokens are signed.

Jump to

Keyboard shortcuts

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