dataselect

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2017 License: Apache-2.0 Imports: 6 Imported by: 1,113

Documentation

Index

Constants

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

List of all property names supported by the UI.

Variables

DefaultDataSelect downloads first 10 items from page 1 with no sort and no metrics.

DefaultDataSelectWithMetrics downloads first 10 items from page 1 with no sort. Also downloads and includes standard metrics.

View Source
var DefaultPagination = NewPaginationQuery(10, 0)

Returns 10 items from page 1

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 NoFilter = &FilterQuery{
	FilterByList: []FilterBy{},
}
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 NoSort = &SortQuery{
	SortByList: []SortBy{},
}

NoSort is as option for no sort.

StandardMetrics query results in a standard metrics being returned. standard metrics are: cpu usage, memory usage and aggregation = sum.

StdMetricsDataSelect does not perform any data select, just downloads standard metrics.

Functions

func PodListMetrics added in v1.6.2

func PodListMetrics(dataList []DataCell, dsQuery *DataSelectQuery,
	metricClient metricapi.MetricClient) metricapi.MetricPromises

PodListMetrics returns metrics for every resource on the dataList without aggregating data.

Types

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
	// Returns true if self value contains or is equal to other value, false otherwise.
	Contains(ComparableValue) bool
}

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 GenericDataSelectWithFilter added in v1.6.1

func GenericDataSelectWithFilter(dataList []DataCell, dsQuery *DataSelectQuery) ([]DataCell, int)

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

func GenericDataSelectWithFilterAndMetrics added in v1.5.1

func GenericDataSelectWithFilterAndMetrics(dataList []DataCell, dsQuery *DataSelectQuery,
	cachedResources *metricapi.CachedResources, metricClient metricapi.MetricClient) (
	[]DataCell, metricapi.MetricPromises, int)

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 *metricapi.CachedResources, metricClient metricapi.MetricClient) (
	[]DataCell, metricapi.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
	FilterQuery     *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, filterQuery *FilterQuery, 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 *metricapi.CachedResources
	// CumulativeMetricsPromises is a list of promises holding aggregated metrics for resources in GenericDataList.
	// The metrics will be calculated after calling GetCumulativeMetrics method.
	CumulativeMetricsPromises metricapi.MetricPromises
	// MetricsPromises is a list of promises holding metrics for resources in GenericDataList.
	// The metrics will be calculated after calling GetMetrics method. Metric will not be
	// aggregated and can are used to display sparklines on pod list.
	MetricsPromises metricapi.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) Filter added in v1.5.1

func (self *DataSelector) Filter() *DataSelector

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

func (*DataSelector) GetCumulativeMetrics

func (self *DataSelector) GetCumulativeMetrics(metricClient metricapi.MetricClient) *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) GetMetrics added in v1.6.2

func (self *DataSelector) GetMetrics(metricClient metricapi.MetricClient) *DataSelector

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

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

Paginates 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 FilterBy added in v1.5.1

type FilterBy struct {
	Property PropertyName
	Value    ComparableValue
}

type FilterQuery added in v1.5.1

type FilterQuery struct {
	FilterByList []FilterBy
}

func NewFilterQuery added in v1.5.1

func NewFilterQuery(filterByListRaw []string) *FilterQuery

NewFilterQuery takes raw filter options list and returns FilterQuery object. For example: ["parameter1", "value1", "parameter2", "value2"] - means that the data should be filtered by parameter1 equals value1 and parameter2 equals value2

type MetricDataCell

type MetricDataCell interface {
	DataCell
	// GetResourceSelector returns ResourceSelector for this resource. The ResourceSelector can be used to get,
	// HeapsterSelector which in turn can be used to download metrics.
	GetResourceSelector() *metricapi.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 metricapi.AggregationModes
}

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 metricapi.AggregationModes) *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

func (StdComparableInt) Contains added in v1.6.1

func (self StdComparableInt) Contains(otherV ComparableValue) bool

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

func (StdComparableRFC3339Timestamp) Contains added in v1.6.1

func (self StdComparableRFC3339Timestamp) Contains(otherV ComparableValue) bool

type StdComparableString

type StdComparableString string

func (StdComparableString) Compare

func (self StdComparableString) Compare(otherV ComparableValue) int

func (StdComparableString) Contains added in v1.6.1

func (self StdComparableString) Contains(otherV ComparableValue) bool

type StdComparableTime

type StdComparableTime time.Time

func (StdComparableTime) Compare

func (self StdComparableTime) Compare(otherV ComparableValue) int

func (StdComparableTime) Contains added in v1.6.1

func (self StdComparableTime) Contains(otherV ComparableValue) bool

Jump to

Keyboard shortcuts

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