metricstore_client

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

README

Metric Store Client

slack.cloudfoundry.org

This is a golang client library for metric-store.

Usage

This repository should be imported as:

import metric-store-client "github.com/cloudfoundry/metric-store-release/src/pkg/client"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client reads from MetricStore via the RESTful or gRPC API.

func NewClient

func NewClient(addr string, opts ...ClientOption) *Client

NewIngressClient creates a Client.

func (*Client) PromQL

func (c *Client) PromQL(
	ctx context.Context,
	query string,
	opts ...PromQLOption,
) (*rpc.PromQL_InstantQueryResult, error)

PromQL issues a PromQL query against Metric Store data.

func (*Client) PromQLRange

func (c *Client) PromQLRange(
	ctx context.Context,
	query string,
	opts ...PromQLOption,
) (*rpc.PromQL_RangeQueryResult, error)

PromQL issues a PromQL query against Metric Store data.

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption configures the MetricStore client.

func WithHTTPClient

func WithHTTPClient(h HTTPClient) ClientOption

WithHTTPClient sets the HTTP client. It defaults to a client that timesout after 5 seconds.

func WithViaGRPC

func WithViaGRPC(opts ...grpc.DialOption) ClientOption

WithViaGRPC enables gRPC instead of HTTP/1 for reading from MetricStore.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface that represents a http.Client.

type Oauth2HTTPClient

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

Oauth2HTTPClient sets the "Authorization" header of any outgoing request. It gets a JWT from the configured Oauth2 server. It only gets a new JWT when a request comes back with a 401.

func NewOauth2HTTPClient

func NewOauth2HTTPClient(oauth2Addr, client, clientSecret string, opts ...Oauth2Option) *Oauth2HTTPClient

NewOauth2HTTPClient creates a new Oauth2HTTPClient.

func (*Oauth2HTTPClient) Do

func (c *Oauth2HTTPClient) Do(req *http.Request) (*http.Response, error)

Do implements HTTPClient. It adds the Authorization header to the request (unless the header already exists). If the token is expired, it will reach out the Oauth2 server and get a new one. The given error CAN be from the request to the Oauth2 server.

Do modifies the given Request. It is invalid to use the same Request instance on multiple go-routines.

type Oauth2Option

type Oauth2Option interface {
	// contains filtered or unexported methods
}

Oauth2Option configures the Oauth2HTTPClient.

func WithOauth2HTTPClient

func WithOauth2HTTPClient(client HTTPClient) Oauth2Option

WithOauth2HTTPClient sets the HTTPClient for the Oauth2HTTPClient. It defaults to the same default as Client.

func WithOauth2HTTPUser

func WithOauth2HTTPUser(username, password string) Oauth2Option

WithOauth2HTTPUser sets the username and password for user authentication.

type PromQLOption

type PromQLOption func(u *url.URL, q url.Values)

PromQLOption configures the URL that is used to submit the query. The RawQuery is set to the decoded query parameters after each option is invoked.

func WithPromQLEnd

func WithPromQLEnd(t time.Time) PromQLOption

func WithPromQLStart

func WithPromQLStart(t time.Time) PromQLOption

func WithPromQLStep

func WithPromQLStep(step string) PromQLOption

func WithPromQLTime

func WithPromQLTime(t time.Time) PromQLOption

WithPromQLTime returns a PromQLOption that configures the 'time' query parameter for a PromQL query.

Directories

Path Synopsis
examples
cf_user_auth command
promql command

Jump to

Keyboard shortcuts

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