emission

package
v1.109.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("emission service")

Error describes internal emission service error.

Functions

This section is empty.

Types

type CalculationInput added in v1.99.1

type CalculationInput struct {
	AmountOfDataInTB float64       // The amount of data in terabytes or terabyte-duration.
	Duration         time.Duration // The Duration over which the data is measured.
	IsTBDuration     bool          // true if AmountOfDataInTB is in terabytes-duration, false if in terabytes.
}

CalculationInput holds input data needed to perform emission impact calculations.

type Config

type Config struct {
	WriteEnergy                    float64 `help:"energy needed to write 1GB of data, in W-hours/GB" default:"0.005"`
	CO2PerEnergy                   float64 `help:"amount of carbon emission per unit of energy, in kg/kW-hours" default:"0.2826"`
	ShortenedDriveLife             float64 `help:"shortened hard drive life period, in years" default:"3"`
	StandardDriveLife              float64 `help:"standard hard drive life period, in years" default:"4"`
	ExtendedDriveLife              float64 `help:"extended hard drive life period, in years" default:"6"`
	NewDriveEmbodiedCarbon         float64 `help:"carbon footprint of producing 1TB HDD, in kg/TB" default:"20"`
	CarbonFromDrivePowering        float64 `help:"carbon from power per year of operations, in kg/TB-year" default:"15.9"`
	RepairedData                   float64 `help:"amount of repaired data, in TB" default:"667"`
	ExpandedData                   float64 `help:"amount of expanded data, in TB" default:"48689"`
	StorjGCPCarbon                 float64 `help:"amount of carbon emission from storj GCP, in kg" default:"3600"`
	StorjCRDBCarbon                float64 `help:"amount of carbon emission from storj CRDB, in kg" default:"2650"`
	StorjEdgeCarbon                float64 `help:"amount of carbon emission from storj Edge, in kg" default:"10924"`
	StorjExpandedNetworkStorage    float64 `help:"amount of expanded network storage, in TB" default:"18933"`
	HyperscalerExpansionFactor     float64 `help:"expansion factor of hyperscaler networks" default:"3"`
	CorporateDCExpansionFactor     float64 `help:"expansion factor of corporate data center networks" default:"4"`
	StorjExpansionFactor           float64 `help:"expansion factor of storj network" default:"2.7"`
	HyperscalerRegionCount         float64 `help:"region count of hyperscaler networks" default:"2"`
	CorporateDCRegionCount         float64 `help:"region count of corporate data center networks" default:"2"`
	StorjRegionCount               float64 `help:"region count of storj network" default:"1"`
	StorjStandardNetworkWeighting  float64 `help:"network weighting of already provisioned, powered drives, in fraction" default:"0.21"`
	StorjNewNetworkWeighting       float64 `help:"network weighting of new nodes, in fraction" default:"0.582"`
	HyperscalerUtilizationFraction float64 `help:"utilization fraction of hyperscaler networks, in fraction" default:"0.75"`
	CorporateDCUtilizationFraction float64 `help:"utilization fraction of corporate data center networks, in fraction" default:"0.40"`
	StorjUtilizationFraction       float64 `help:"utilization fraction of storj network, in fraction" default:"0.85"`
	AverageCO2SequesteredByTree    float64 `help:"weighted average CO2 sequestered by a medium growth coniferous or deciduous tree, in kgCO2e/tree" default:"60"`
}

Config contains configurable values for emission service.

type Impact

type Impact struct {
	EstimatedKgCO2eStorj                       float64
	EstimatedKgCO2eHyperscaler                 float64
	EstimatedKgCO2eCorporateDC                 float64
	EstimatedFractionSavingsAgainstHyperscaler float64
	EstimatedFractionSavingsAgainstCorporateDC float64
}

Impact represents emission impact from different sources.

type Row

type Row [modalityCount]Val

Row holds data row of predefined number of values.

type Service

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

Service is an emission service. Performs emissions impact calculations.

architecture: Service

func NewService

func NewService(config Config) *Service

NewService creates a new Service with the given configuration.

func (*Service) CalculateImpact

func (sv *Service) CalculateImpact(input *CalculationInput) (*Impact, error)

CalculateImpact calculates emission impact coming from different sources e.g. Storj, hyperscaler or corporateDC.

func (*Service) CalculateSavedTrees added in v1.99.1

func (sv *Service) CalculateSavedTrees(impact float64) int64

CalculateSavedTrees calculates saved trees count based on emission impact.

type Unit added in v1.99.1

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

Unit represents a set of unit dimensions. Unit{byte: 0, watt: 0, hour: 1, kilogram: 0} means hour (H). Unit{byte: 1, watt: 0, hour: -1, kilogram: 0} means byte/hour (B/H). Unit{byte: -1, watt: 0, hour: -1, kilogram: 1} means kg/byte-hour (kg/B*H).

func (*Unit) Div added in v1.99.1

func (u *Unit) Div(b Unit)

Div divides existing Unit by a given one.

func (*Unit) Mul added in v1.99.1

func (u *Unit) Mul(b Unit)

Mul multiplies existing Unit by a given one.

func (*Unit) String added in v1.99.1

func (u *Unit) String() string

String returns string representation of the Unit.

func (*Unit) Value added in v1.99.1

func (u *Unit) Value(v float64) Val

Value creates new Val from existing Unit.

type Val

type Val struct {
	Value float64
	Unit  Unit
}

Val represents a value which consists of the numeric value itself and it's dimensions e.g. 1 W. It may be used to represent a really complex value e.g. 1 W / H or 0.005 W * H / B.

func (Val) Add

func (a Val) Add(b Val) (Val, error)

Add sums two Val instances with the same dimensions.

func (Val) Div

func (a Val) Div(b Val) Val

Div divides one Val by a given one and returns new Val. It adjusts both the amount and the dimensions accordingly.

func (Val) Mul

func (a Val) Mul(b Val) Val

Mul multiplies existing Val with a given one and returns new Val. It adjusts both the amount and the dimensions accordingly.

func (Val) String

func (a Val) String() string

String returns string representation of the Val.

func (Val) Sub

func (a Val) Sub(b Val) (Val, error)

Sub subtracts one Val from another if they have the same dimensions.

Jump to

Keyboard shortcuts

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