dataselect

package
v1.4.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameProperty              = "name"
	CreationTimestampProperty = "creationTimestamp"
	NamespaceProperty         = "namespace"
)

List of all property names supported by the UI.

Variables

View Source
var EmptyPagination = NewPaginationQuery(0, 0)

No items will be returned

NoDataSelect is an option for no data select (same data will be returned).

View Source
var NoMetrics = NewMetricQuery(nil, nil)
View Source
var NoPagination = NewPaginationQuery(-1, -1)

By default backend pagination will not be applied.

View Source
var NoResourceCache = &CachedResources{}
View Source
var NoSort = &SortQuery{
	SortByList: []SortBy{},
}

NoSort is as option for no sort.

Functions

This section is empty.

Types

type CachedResources

type CachedResources struct {
	Pods []api.Pod
}

CachedResources contains all resources that may be required by DataSelect functions. Depending on the need you may have to provide DataSelect with resources it requires, for example resource like deployment will need Pods in order to calculate its metrics.

type ComparableValue

type ComparableValue interface {
	// Compares self with other value. Returns 1 if other value is smaller, 0 if they are the same, -1 if other is larger.
	Compare(ComparableValue) int
}

ComparableValue hold any value that can be compared to its own kind.

type DataCell

type DataCell interface {
	// GetPropertyAtIndex returns the property of this data cell.
	// Value returned has to have Compare method which is required by Sort functionality of DataSelect.
	GetProperty(PropertyName) ComparableValue
}

GenericDataCell describes the interface of the data cell that contains all the necessary methods needed to perform complex data selection GenericDataSelect takes a list of these interfaces and performs selection operation. Therefore as long as the list is composed of GenericDataCells you can perform any data selection!

func GenericDataSelect

func GenericDataSelect(dataList []DataCell, dsQuery *DataSelectQuery) []DataCell

GenericDataSelect takes a list of GenericDataCells and DataSelectQuery and returns selected data as instructed by dsQuery.

func GenericDataSelectWithMetrics

func GenericDataSelectWithMetrics(dataList []DataCell, dsQuery *DataSelectQuery, cachedResources *CachedResources, heapsterClient client.HeapsterClient) ([]DataCell, metric.MetricPromises)

GenericDataSelect takes a list of GenericDataCells and DataSelectQuery and returns selected data as instructed by dsQuery.

type DataSelectQuery

type DataSelectQuery struct {
	PaginationQuery *PaginationQuery
	SortQuery       *SortQuery
	//	Filter     *FilterQuery
	MetricQuery *MetricQuery
}

Options for GenericDataSelect which takes []GenericDataCell and returns selected data. Can be extended to include any kind of selection - for example filtering. Currently included only Pagination and Sort options.

func NewDataSelectQuery

func NewDataSelectQuery(paginationQuery *PaginationQuery, sortQuery *SortQuery, graphQuery *MetricQuery) *DataSelectQuery

NewDataSelectQuery creates DataSelectQuery object from simpler data select queries.

type DataSelector

type DataSelector struct {
	// GenericDataList hold generic data cells that are being selected.
	GenericDataList []DataCell
	// DataSelectQuery holds instructions for data select.
	DataSelectQuery *DataSelectQuery
	// CachedResources stores resources that may be needed during data selection process
	CachedResources *CachedResources
	// CumulativeMetricsPromises is a list of promises holding aggregated metrics for resources in GenericDataList.
	// The metrics will be calculated after calling GetCumulativeMetrics method.
	CumulativeMetricsPromises metric.MetricPromises
}

SelectableData contains all the required data to perform data selection. It implements sort.Interface so its sortable under sort.Sort You can use its Select method to get selected GenericDataCell list.

func (*DataSelector) GetCumulativeMetrics

func (self *DataSelector) GetCumulativeMetrics(client client.HeapsterClient) *DataSelector

GetCumulativeMetrics downloads and aggregates metrics for data cells currently present in self.GenericDataList as instructed by MetricQuery and inserts resulting MetricPromises to self.CumulativeMetricsPromises.

func (DataSelector) Len

func (self DataSelector) Len() int

Len returns the length of data inside SelectableData.

func (DataSelector) Less

func (self DataSelector) Less(i, j int) bool

Less compares 2 indices inside SelectableData and returns true if first index is larger.

func (*DataSelector) Paginate

func (self *DataSelector) Paginate() *DataSelector

Paginate paginetes the data inside as instructed by DataSelectQuery and returns itself to allow method chaining.

func (*DataSelector) Sort

func (self *DataSelector) Sort() *DataSelector

Sort sorts the data inside as instructed by DataSelectQuery and returns itself to allow method chaining.

func (DataSelector) Swap

func (self DataSelector) Swap(i, j int)

Swap swaps 2 indices inside SelectableData.

type MetricDataCell

type MetricDataCell interface {
	// GetPropertyAtIndex returns the property of this data cell.
	// Value returned has to have Compare method which is required by Sort functionality of DataSelect.
	GetProperty(PropertyName) ComparableValue
	// GetResourceSelector returns ResourceSelector for this resource. The ResourceSelector can be used to get,
	// HeapsterSelector which in turn can be used to download metrics.
	GetResourceSelector() *metric.ResourceSelector
}

MetricDataCell extends interface of DataCells and additionally supports metric download.

type MetricQuery

type MetricQuery struct {
	// Metrics to download, all available metric names can be found here:
	// https://github.com/kubernetes/heapster/blob/master/docs/storage-schema.md
	MetricNames []string
	// Aggregations to be performed for each metric. Check available aggregations in aggregation.go.
	// If empty, default aggregation will be used (sum).
	Aggregations metric.AggregationNames
}

MetricQuery holds parameters for metric extraction process. It accepts list of metrics to be downloaded and a list of aggregations that should be performed for each metric. Query has this format metrics=metric1,metric2,...&aggregations=aggregation1,aggregation2,...

func NewMetricQuery

func NewMetricQuery(metricNames []string, aggregations metric.AggregationNames) *MetricQuery

NewMetricQuery returns a metric query from provided settings.

type PaginationQuery

type PaginationQuery struct {
	// How many items per page should be returned
	ItemsPerPage int
	// Number of page that should be returned when pagination is applied to the list
	Page int
}

PaginationQuery structure represents pagination settings

func NewPaginationQuery

func NewPaginationQuery(itemsPerPage, page int) *PaginationQuery

NewPaginationQuery return pagination query structure based on given parameters

func (*PaginationQuery) GetPaginationSettings

func (p *PaginationQuery) GetPaginationSettings(itemsCount int) (startIndex int, endIndex int)

GetPaginationSettings based on number of items and pagination query parameters returns start and end index that can be used to return paginated list of items.

func (*PaginationQuery) IsPageAvailable

func (p *PaginationQuery) IsPageAvailable(itemsCount, startingIndex int) bool

IsPageAvailable returns true if at least one element can be placed on page. False otherwise

func (*PaginationQuery) IsValidPagination

func (p *PaginationQuery) IsValidPagination() bool

IsValidPagination returns true if pagination has non negative parameters

type PropertyName

type PropertyName string

PropertyName is used to get the value of certain property of data cell. For example if we want to get the namespace of certain Deployment we can use DeploymentCell.GetProperty(NamespaceProperty)

type SortBy

type SortBy struct {
	Property  PropertyName
	Ascending bool
}

SortBy holds the name of the property that should be sorted and whether order should be ascending or descending.

type SortQuery

type SortQuery struct {
	SortByList []SortBy
}

SortQuery holds options for sort functionality of data select.

func NewSortQuery

func NewSortQuery(sortByListRaw []string) *SortQuery

NewSortQuery takes raw sort options list and returns SortQuery object. For example: ["a", "parameter1", "d", "parameter2"] - means that the data should be sorted by parameter1 (ascending) and later - for results that return equal under parameter 1 sort - by parameter2 (descending)

type StdComparableInt

type StdComparableInt int

func (StdComparableInt) Compare

func (self StdComparableInt) Compare(otherV ComparableValue) int

type StdComparableRFC3339Timestamp

type StdComparableRFC3339Timestamp string

StdComparableRFC3339Timestamp takes RFC3339 Timestamp strings and compares them as TIMES. In case of time parsing error compares values as strings.

func (StdComparableRFC3339Timestamp) Compare

func (self StdComparableRFC3339Timestamp) Compare(otherV ComparableValue) int

type StdComparableString

type StdComparableString string

func (StdComparableString) Compare

func (self StdComparableString) Compare(otherV ComparableValue) int

type StdComparableTime

type StdComparableTime time.Time

func (StdComparableTime) Compare

func (self StdComparableTime) Compare(otherV ComparableValue) int

Jump to

Keyboard shortcuts

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