irondb

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package irondb provides proxy origin support for IRONdb databases.

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 values provide access to IRONdb and implement the Trickster proxy client interface.

func NewClient

func NewClient(name string, oc *config.OriginConfig, cache cache.Cache) (*Client, error)

NewClient returns a new Client Instance

func (Client) BaseURL

func (c Client) BaseURL() *url.URL

BaseURL returns a URL in the form of scheme://host/path based on the proxy configuration.

func (Client) BuildUpstreamURL

func (c Client) BuildUpstreamURL(r *http.Request) *url.URL

BuildUpstreamURL will merge the downstream request with the BaseURL to construct the full upstream URL.

func (*Client) CAQLHandler

func (c *Client) CAQLHandler(w http.ResponseWriter, r *http.Request)

CAQLHandler handles CAQL requests for timeseries data and processes them through the delta proxy cache.

func (*Client) Cache

func (c *Client) Cache() cache.Cache

Cache returns a handle to the Cache instance used by this Client.

func (*Client) Configuration

func (c *Client) Configuration() *config.OriginConfig

Configuration returns the upstream Configuration for this Client.

func (*Client) DefaultPathConfigs

func (c *Client) DefaultPathConfigs(oc *config.OriginConfig) map[string]*config.PathConfig

DefaultPathConfigs returns the default PathConfigs for the given OriginType

func (*Client) FastForwardURL

func (c *Client) FastForwardURL(r *http.Request) (*url.URL, error)

FastForwardURL returns the url to fetch the Fast Forward value based on a timerange URL.

func (*Client) FetchHandler

func (c *Client) FetchHandler(w http.ResponseWriter, r *http.Request)

FetchHandler handles requests for numeric timeseries data with specified spans and processes them through the delta proxy cache.

func (*Client) FindHandler

func (c *Client) FindHandler(w http.ResponseWriter, r *http.Request)

FindHandler handles requests to find metirc information and processes them through the object proxy cache.

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

HTTPClient returns the HTTP Transport this client is using.

func (*Client) Handlers

func (c *Client) Handlers() map[string]http.Handler

Handlers returns a map of the HTTP Handlers the client has registered

func (*Client) HealthHandler

func (c *Client) HealthHandler(w http.ResponseWriter, r *http.Request)

HealthHandler checks the health of the Configured Upstream Origin

func (*Client) HistogramHandler

func (c *Client) HistogramHandler(w http.ResponseWriter, r *http.Request)

HistogramHandler handles requests for historgam timeseries data and processes them through the delta proxy cache.

func (*Client) MarshalTimeseries

func (c *Client) MarshalTimeseries(ts timeseries.Timeseries) ([]byte, error)

MarshalTimeseries converts a Timeseries into a JSON blob for cache storage.

func (*Client) Name

func (c *Client) Name() string

Name returns the name of the origin Configuration proxied by the Client.

func (*Client) ParseTimeRangeQuery

func (c *Client) ParseTimeRangeQuery(
	r *http.Request) (*timeseries.TimeRangeQuery, error)

ParseTimeRangeQuery parses the key parts of a TimeRangeQuery from the inbound HTTP Request.

func (*Client) ProxyHandler

func (c *Client) ProxyHandler(w http.ResponseWriter, r *http.Request)

ProxyHandler sends a request through the basic reverse proxy to the origin for non-cacheable API calls.

func (*Client) RawHandler

func (c *Client) RawHandler(w http.ResponseWriter, r *http.Request)

RawHandler handles requests for raw numeric timeseries data and processes them through the delta proxy cache.

func (*Client) RollupHandler

func (c *Client) RollupHandler(w http.ResponseWriter, r *http.Request)

RollupHandler handles requests for numeric timeseries data with specified spans and processes them through the delta proxy cache.

func (*Client) SetCache

func (c *Client) SetCache(cc cache.Cache)

SetCache sets the Cache object the client will use for caching origin content

func (Client) SetExtent

func (c Client) SetExtent(r *http.Request, trq *timeseries.TimeRangeQuery, extent *timeseries.Extent)

SetExtent will change the upstream request query to use the provided Extent.

func (*Client) StateHandler

func (c *Client) StateHandler(w http.ResponseWriter, r *http.Request)

StateHandler handles requests for state data and processes them through the basic reverse proxy to the origin for non-cacheable API calls.

func (*Client) TextHandler

func (c *Client) TextHandler(w http.ResponseWriter, r *http.Request)

TextHandler handles requests for text timeseries data and processes them through the delta proxy cache.

func (Client) UnmarshalInstantaneous

func (c Client) UnmarshalInstantaneous(
	data []byte) (timeseries.Timeseries, error)

UnmarshalInstantaneous is not used for IRONdb origins and is here to conform to the Client interface.

func (*Client) UnmarshalTimeseries

func (c *Client) UnmarshalTimeseries(data []byte) (timeseries.Timeseries,
	error)

UnmarshalTimeseries converts a JSON blob into a Timeseries value.

type DF4Info

type DF4Info struct {
	Count  int64 `json:"count"`
	Start  int64 `json:"start"`
	Period int64 `json:"period"`
}

DF4Info values contain information about the timestamps of the data elements in DF4 data series.

type DF4SeriesEnvelope

type DF4SeriesEnvelope struct {
	Data         [][]interface{}          `json:"data"`
	Meta         []map[string]interface{} `json:"meta,omitempty"`
	Ver          string                   `json:"version,omitempty"`
	Head         DF4Info                  `json:"head"`
	StepDuration time.Duration            `json:"step,omitempty"`
	ExtentList   timeseries.ExtentList    `json:"extents,omitempty"`
}

DF4SeriesEnvelope values represent DF4 format time series data from the IRONdb API.

func (*DF4SeriesEnvelope) Clone

Clone returns a perfect copy of the base Timeseries.

func (*DF4SeriesEnvelope) CropToRange

func (se *DF4SeriesEnvelope) CropToRange(e timeseries.Extent)

CropToRange crops down a Timeseries value to the provided Extent. Crop assumes the base Timeseries is already sorted, and will corrupt an unsorted Timeseries.

func (*DF4SeriesEnvelope) CropToSize

func (se *DF4SeriesEnvelope) CropToSize(sz int, t time.Time,
	lur timeseries.Extent)

CropToSize reduces the number of elements in the Timeseries to the provided count, by evicting elements using a least-recently-used methodology. Any timestamps newer than the provided time are removed before sizing, in order to support backfill tolerance. The provided extent will be marked as used during crop.

func (*DF4SeriesEnvelope) Extents

func (se *DF4SeriesEnvelope) Extents() timeseries.ExtentList

Extents returns the Timeseries's extent list.

func (*DF4SeriesEnvelope) Merge

func (se *DF4SeriesEnvelope) Merge(sort bool,
	collection ...timeseries.Timeseries)

Merge merges the provided Timeseries list into the base Timeseries (in the order provided) and optionally sorts the merged Timeseries.

func (*DF4SeriesEnvelope) SeriesCount

func (se *DF4SeriesEnvelope) SeriesCount() int

SeriesCount returns the number of individual series in the Timeseries value.

func (*DF4SeriesEnvelope) SetExtents

func (se *DF4SeriesEnvelope) SetExtents(extents timeseries.ExtentList)

SetExtents overwrites a Timeseries's known extents with the provided extent list.

func (*DF4SeriesEnvelope) SetStep

func (se *DF4SeriesEnvelope) SetStep(step time.Duration)

SetStep sets the step for the Timeseries.

func (*DF4SeriesEnvelope) Size

func (se *DF4SeriesEnvelope) Size() int

Size returns the approximate memory utilization in bytes of the timeseries

func (*DF4SeriesEnvelope) Sort

func (se *DF4SeriesEnvelope) Sort()

Sort sorts all data in the Timeseries chronologically by their timestamp.

func (*DF4SeriesEnvelope) Step

func (se *DF4SeriesEnvelope) Step() time.Duration

Step returns the step for the Timeseries.

func (*DF4SeriesEnvelope) TimestampCount

func (se *DF4SeriesEnvelope) TimestampCount() int

TimestampCount returns the number of unique timestamps across the timeseries.

func (*DF4SeriesEnvelope) ValueCount

func (se *DF4SeriesEnvelope) ValueCount() int

ValueCount returns the count of all data values across all Series in the Timeseries value.

type DataPoint

type DataPoint struct {
	Time  time.Time
	Step  uint32
	Value interface{}
}

DataPoint values represent a single data element of a time series data response from the IRONdb API.

func (*DataPoint) MarshalJSON

func (dp *DataPoint) MarshalJSON() ([]byte, error)

MarshalJSON encodes a data point value into a JSON byte slice.

func (*DataPoint) UnmarshalJSON

func (dp *DataPoint) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes a JSON byte slice into this data point value.

type DataPoints

type DataPoints []DataPoint

DataPoints values represent sortable slices of data point values.

func (DataPoints) Len

func (dps DataPoints) Len() int

Len returns the length of an array of Prometheus model.Times

func (DataPoints) Less

func (dps DataPoints) Less(i, j int) bool

Less returns true if the value at index i comes before the value at index j.

func (DataPoints) Swap

func (dps DataPoints) Swap(i, j int)

Swap modifies a slice of data tuples by swapping the values in indexes i and j.

type SeriesEnvelope

type SeriesEnvelope struct {
	Data         DataPoints            `json:"data"`
	ExtentList   timeseries.ExtentList `json:"extents,omitempty"`
	StepDuration time.Duration         `json:"step,omitempty"`
}

SeriesEnvelope values represent a time series data response from the IRONdb API.

func (*SeriesEnvelope) Clone

func (se *SeriesEnvelope) Clone() timeseries.Timeseries

Clone returns a perfect copy of the base Timeseries.

func (*SeriesEnvelope) CropToRange

func (se *SeriesEnvelope) CropToRange(e timeseries.Extent)

CropToRange crops down a Timeseries value to the provided Extent. Crop assumes the base Timeseries is already sorted, and will corrupt an unsorted Timeseries.

func (*SeriesEnvelope) CropToSize

func (se *SeriesEnvelope) CropToSize(sz int, t time.Time,
	lur timeseries.Extent)

CropToSize reduces the number of elements in the Timeseries to the provided count, by evicting elements using a least-recently-used methodology. Any timestamps newer than the provided time are removed before sizing, in order to support backfill tolerance. The provided extent will be marked as used during crop.

func (*SeriesEnvelope) Extents

func (se *SeriesEnvelope) Extents() timeseries.ExtentList

Extents returns the Timeseries's extent list.

func (*SeriesEnvelope) MarshalJSON

func (se *SeriesEnvelope) MarshalJSON() ([]byte, error)

MarshalJSON encodes a series envelope value into a JSON byte slice.

func (*SeriesEnvelope) Merge

func (se *SeriesEnvelope) Merge(sort bool,
	collection ...timeseries.Timeseries)

Merge merges the provided Timeseries list into the base Timeseries (in the order provided) and optionally sorts the merged Timeseries.

func (*SeriesEnvelope) SeriesCount

func (se *SeriesEnvelope) SeriesCount() int

SeriesCount returns the number of individual series in the Timeseries value.

func (*SeriesEnvelope) SetExtents

func (se *SeriesEnvelope) SetExtents(extents timeseries.ExtentList)

SetExtents overwrites a Timeseries's known extents with the provided extent list.

func (*SeriesEnvelope) SetStep

func (se *SeriesEnvelope) SetStep(step time.Duration)

SetStep sets the step for the Timeseries.

func (*SeriesEnvelope) Size

func (se *SeriesEnvelope) Size() int

Size returns the approximate memory utilization in bytes of the timeseries

func (*SeriesEnvelope) Sort

func (se *SeriesEnvelope) Sort()

Sort sorts all data in the Timeseries chronologically by their timestamp.

func (*SeriesEnvelope) Step

func (se *SeriesEnvelope) Step() time.Duration

Step returns the step for the Timeseries.

func (*SeriesEnvelope) TimestampCount

func (se *SeriesEnvelope) TimestampCount() int

TimestampCount returns the number of unique timestamps across the timeseries.

func (*SeriesEnvelope) UnmarshalJSON

func (se *SeriesEnvelope) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes a JSON byte slice into this data point value.

func (*SeriesEnvelope) ValueCount

func (se *SeriesEnvelope) ValueCount() int

ValueCount returns the count of all data values across all Series in the Timeseries value.

Jump to

Keyboard shortcuts

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