clickhouse

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package clickhouse provides the ClickHouse origin type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrNotEnoughFields

func ErrNotEnoughFields(count int) error

ErrNotEnoughFields returns an error when there are too few number of fields

func NewClient

func NewClient(name string, oc *oo.Options, router http.Handler,
	cache cache.Cache) (origins.Client, error)

NewClient returns a new Client Instance

Types

type Client

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

Client Implements the Proxy Client Interface

func (*Client) Cache

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

Cache returns and handle to the Cache instance used by the Client

func (*Client) Configuration

func (c *Client) Configuration() *oo.Options

Configuration returns the upstream Configuration for this Client

func (*Client) DefaultPathConfigs

func (c *Client) DefaultPathConfigs(oc *oo.Options) map[string]*po.Options

DefaultPathConfigs returns the default PathConfigs for the given OriginType

func (*Client) FastForwardRequest

func (c *Client) FastForwardRequest(r *http.Request) (*http.Request, error)

FastForwardRequest is not used for ClickHouse and is here to conform to the Proxy Client interface

func (*Client) HTTPClient

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

HTTPClient returns the HTTP Transport the 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) MarshalTimeseries

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

MarshalTimeseries converts a Timeseries into a JSON blob

func (*Client) Name

func (c *Client) Name() string

Name returns the name of the upstream 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, and services non-cacheable InfluxDB API calls

func (*Client) QueryHandler

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

QueryHandler handles timeseries requests for ClickHouse and processes them through the delta proxy cache

func (*Client) QueryRangeHandler

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

QueryRangeHandler is not used for ClickHouse and is here to conform to the Proxy Client interface

func (*Client) Router

func (c *Client) Router() http.Handler

Router returns the http.Handler that handles request routing for this Client

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) UnmarshalInstantaneous

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

UnmarshalInstantaneous is not used for ClickHouse and is here to conform to the Proxy Client interface

func (*Client) UnmarshalTimeseries

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

UnmarshalTimeseries converts a JSON blob into a Timeseries

type DataSet

type DataSet struct {
	Metric map[string]interface{}
	Points []Point
}

DataSet ...

type FieldDefinition

type FieldDefinition struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

FieldDefinition ...

type Point

type Point struct {
	Timestamp time.Time
	Value     float64
}

Point ...

type Points

type Points []Point

Points ...

func (Points) Len

func (p Points) Len() int

Len returns the length of a slice of time series data points

func (Points) Less

func (p Points) Less(i, j int) bool

Less returns true if i comes before j

func (Points) Swap

func (p Points) Swap(i, j int)

Swap modifies a slice of time series data points by swapping the values in indexes i and j

type Response

type Response struct {
	Meta         []FieldDefinition     `json:"meta"`
	RawData      []ResponseValue       `json:"data"`
	Rows         int                   `json:"rows"`
	Order        []string              `json:"-"`
	StepDuration time.Duration         `json:"step,omitempty"`
	ExtentList   timeseries.ExtentList `json:"extents,omitempty"`
}

Response is the JSON responose document structure for ClickHouse query results

func (*Response) MarshalJSON

func (rsp *Response) MarshalJSON() ([]byte, error)

MarshalJSON ...

type ResponseValue

type ResponseValue map[string]interface{}

ResponseValue ...

func (ResponseValue) Parts

func (rv ResponseValue) Parts(timeKey, valKey string) (string, time.Time, float64, ResponseValue)

Parts ...

func (ResponseValue) ToJSON

func (rv ResponseValue) ToJSON(order []string) []byte

ToJSON ...

type ResultsEnvelope

type ResultsEnvelope struct {
	Meta         []FieldDefinition            `json:"meta"`
	Data         map[string]*DataSet          `json:"data"`
	StepDuration time.Duration                `json:"step,omitempty"`
	ExtentList   timeseries.ExtentList        `json:"extents,omitempty"`
	Serializers  map[string]func(interface{}) `json:"-"`
	SeriesOrder  []string                     `json:"series_order,omitempty"`
	// contains filtered or unexported fields
}

ResultsEnvelope is the ClickHouse document structure optimized for time series manipulation

func (*ResultsEnvelope) Clone

Clone returns a perfect copy of the base Timeseries

func (*ResultsEnvelope) CropToRange

func (re *ResultsEnvelope) CropToRange(e timeseries.Extent)

CropToRange reduces the Timeseries down to timestamps contained within the provided Extents (inclusive). CropToRange assumes the base Timeseries is already sorted, and will corrupt an unsorted Timeseries

func (*ResultsEnvelope) CropToSize

func (re *ResultsEnvelope) 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 (*ResultsEnvelope) Extents

func (re *ResultsEnvelope) Extents() timeseries.ExtentList

Extents returns the Timeseries's ExentList

func (ResultsEnvelope) MarshalJSON

func (re ResultsEnvelope) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (*ResultsEnvelope) Merge

func (re *ResultsEnvelope) 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 (*ResultsEnvelope) SeriesCount

func (re *ResultsEnvelope) SeriesCount() int

SeriesCount returns the number of individual Series in the Timeseries object

func (*ResultsEnvelope) SetExtents

func (re *ResultsEnvelope) SetExtents(extents timeseries.ExtentList)

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

func (*ResultsEnvelope) SetStep

func (re *ResultsEnvelope) SetStep(step time.Duration)

SetStep sets the step for the Timeseries

func (*ResultsEnvelope) Size

func (re *ResultsEnvelope) Size() int

Size returns the approximate memory utilization in bytes of the timeseries

func (*ResultsEnvelope) Sort

func (re *ResultsEnvelope) Sort()

Sort sorts all Values in each Series chronologically by their timestamp

func (*ResultsEnvelope) Step

func (re *ResultsEnvelope) Step() time.Duration

Step returns the step for the Timeseries

func (*ResultsEnvelope) TimestampCount

func (re *ResultsEnvelope) TimestampCount() int

TimestampCount returns the number of unique timestamps across the timeseries

func (*ResultsEnvelope) UnmarshalJSON

func (re *ResultsEnvelope) UnmarshalJSON(b []byte) error

UnmarshalJSON ...

func (*ResultsEnvelope) ValueCount

func (re *ResultsEnvelope) ValueCount() int

ValueCount returns the count of all values across all Series in the Timeseries object

Jump to

Keyboard shortcuts

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