calculator

package
v0.0.0-...-a4d1c61 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CostCalculator

type CostCalculator interface {
	// CalculateCost calculates the Rate at which a group of resources should be charged for.
	CalculateCost(resources []Resource) (Rate, error)
}

CostCalculator holds a method to calculate the cost of a group of resources.

type Rate

type Rate struct {
	// Amount is the money a resource costs in the minimum Currency value (e.g. cents for USD) at a certain Frequency.
	Amount uint

	// Currency is the ISO 4217 currency code in lowercase format.
	Currency string

	// Frequency is the frequency at which a resource gets charged.
	// As an example, setting this to time.Hour indicates a rate of `Amount` credits per hour.
	Frequency time.Duration
}

Rate is the rate at what a certain resource is charged.

func AggregateRates

func AggregateRates(rates []Rate) Rate

AggregateRates aggregates the given rates and returns the representation in hours.

func (Rate) Sum

func (r Rate) Sum(rate Rate) Rate

Sum merges the current rate with the rate given as an argument, and returns the sum of both values expressed in hours.

type Resource

type Resource struct {
	// Values contains a set of arbitrary values used to calculate the Rate of this resource.
	Values map[string]interface{}
}

Resource groups a set of fields from a resource consumed by cloudsim. It's used to calculate the cost at which the resource should be charged for.

Jump to

Keyboard shortcuts

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