distributor

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterToSQLPredicates

func FilterToSQLPredicates(filters types.CostFilters) *sql.Predicate

FilterToSQLPredicates create sql predicate from filters.

Types

type CalculateInfo

type CalculateInfo struct {
	ItemCoefficientPerConn map[string]map[object.ID]float64
	ItemCountPerConn       map[object.ID]int
	CostPerConn            map[object.ID]CostPerConnector
	ItemConnIDs            map[string][]object.ID
}

type Cost

type Cost struct {
	Currency         int     `json:"currency,omitempty"`
	TotalCost        float64 `json:"totalCost,omitempty"`
	SharedCost       float64 `json:"sharedCost,omitempty"`
	CPUCost          float64 `json:"cpuCost,omitempty"`
	GPUCost          float64 `json:"gpuCost,omitempty"`
	RAMCost          float64 `json:"ramCost,omitempty"`
	PVCost           float64 `json:"pvCost,omitempty"`
	LoadBalancerCost float64 `json:"loadBalancerCost,omitempty"`
}

type CostPerConnector

type CostPerConnector struct {
	ConnectorID    object.ID `json:"connectorID,omitempty"`
	TotalCost      float64   `json:"totalCost,omitempty"`
	IdleCost       float64   `json:"idleCost,omitempty"`
	ManagementCost float64   `json:"managementCost,omitempty"`
	WorkloadCost   float64   `json:"workloadCost,omitempty"`
}

type Distributor

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

Distributor support use input condition to query resources costs, and split the shared costs base on the condition defined, while the condition with the step(day, month etc.), will return the resource cost for each time bucket, like namespace cost per day, without step will return the resource total cost within the queried time range.

func New

func New(client model.ClientSet) *Distributor

func (*Distributor) Distribute

func (d *Distributor) Distribute(
	ctx context.Context,
	startTime,
	endTime time.Time,
	cond types.QueryCondition,
) ([]Resource, int, error)

type ItemSharedCost

type ItemSharedCost struct {
	Option      *types.ItemSharedOption
	SharedCosts map[object.ID]float64
}

type Resource

type Resource struct {
	Cost

	ItemName  string     `json:"itemName,omitempty"`
	StartTime *time.Time `json:"startTime,omitempty"`
	EndTime   *time.Time `json:"endTime,omitempty"`
}

type SharedCostConnectors

type SharedCostConnectors struct {
	Idle       *types.IdleShareOption
	Management *types.ManagementShareOption
	Items      []ItemSharedCost
}

Jump to

Keyboard shortcuts

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