usage

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateTierBuckets

func CalculateTierBuckets(requestCount decimal.Decimal, tierLimits []int) []decimal.Decimal

func CreateUsageFile

func CreateUsageFile(path string) error

CreateUsageFile creates a blank usage file if it does not exists

func ResourceUsagesToYAML

func ResourceUsagesToYAML(resourceUsages []*ResourceUsage) (yamlv3.Node, bool)

Types

type ContextEnv

type ContextEnv struct{}

type ReferenceFile

type ReferenceFile struct {
	*UsageFile
}

ReferenceFile represents the reference example usage file

func LoadReferenceFile

func LoadReferenceFile() (*ReferenceFile, error)

LoadReferenceFile loads the reference example usage file

func (*ReferenceFile) FindMatchingResourceTypeUsage

func (u *ReferenceFile) FindMatchingResourceTypeUsage(resourceType string) *ResourceUsage

func (*ReferenceFile) FindMatchingResourceUsage

func (u *ReferenceFile) FindMatchingResourceUsage(name string) *ResourceUsage

FindMatchingResourceUsage returns the matching resource usage for the given resource name by looking for a resource with the same resource type

func (*ReferenceFile) SetDefaultValues

func (u *ReferenceFile) SetDefaultValues()

SetDefaultValues updates the reference file to strip the values and set the default values

type ReplaceResourceUsagesOpts

type ReplaceResourceUsagesOpts struct {
	OverrideValueType bool
}

type ResourceUsage

type ResourceUsage struct {
	Name  string
	Items []*engine.ConsumptionField
}

ResourceUsage represents a resource block in the usage file

func ResourceUsagesFromYAML

func ResourceUsagesFromYAML(raw yamlv3.Node) ([]*ResourceUsage, error)

func (*ResourceUsage) Map

func (r *ResourceUsage) Map() map[string]interface{}

func (*ResourceUsage) MergeResourceUsage

func (r *ResourceUsage) MergeResourceUsage(src *ResourceUsage)

MergeResourceUsage merge ResourceItem from src to r without overriding r

type SyncResult

type SyncResult struct {
	ResourceCount    int
	EstimationCount  int
	EstimationErrors map[string]error
}

func SyncUsageData

func SyncUsageData(projectCtx *settings.ProjectSession, usageFile *UsageFile, projects []*engine.Workspace) (*SyncResult, error)

func (*SyncResult) Merge

func (s *SyncResult) Merge(other *SyncResult)

func (*SyncResult) ProjectContext

func (s *SyncResult) ProjectContext() map[string]interface{}

type UsageFile

type UsageFile struct {
	Version string `yaml:"version"`
	// We represent resource type usage in using a YAML node so we have control over the comments
	RawResourceTypeUsage yamlv3.Node `yaml:"resource_type_default_usage"`
	// The raw usage is then parsed into this struct
	ResourceTypeUsages []*ResourceUsage `yaml:"-"`
	// We represent resource usage in using a YAML node so we have control over the comments
	RawResourceUsage yamlv3.Node `yaml:"resource_usage"`
	// The raw usage is then parsed into this struct
	ResourceUsages []*ResourceUsage `yaml:"-"`
}

func LoadUsageFile

func LoadUsageFile(path string) (*UsageFile, error)

func LoadUsageFileFromString

func LoadUsageFileFromString(s string) (*UsageFile, error)

func NewBlankUsageFile

func NewBlankUsageFile() *UsageFile

func (*UsageFile) InvalidKeys

func (u *UsageFile) InvalidKeys() ([]string, error)

InvalidKeys returns a list of keys that are invalid in the usage file. It currently checks the reference usage file for a list of valid keys. In the future we will want this to usage the resource usage schema structs as well.

func (*UsageFile) ToUsageDataMap

func (u *UsageFile) ToUsageDataMap() engine.ConsumptionMap

func (*UsageFile) WriteToPath

func (u *UsageFile) WriteToPath(path string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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