computeengine

package
v0.0.0-...-36f5383 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: OSL-3.0 Imports: 30 Imported by: 1 module, 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

Overview

Package computeengine provides GCP Compute Engine Committed Use Discounts client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPaymentOption

func CheckPaymentOption(payment string) error

CheckPaymentOption accepts the spellings callers send for a known option and rejects anything else, so a typo is not mistaken for a monthly request.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited reports whether err is a throttle worth retrying after a backoff: HTTP 429, gRPC RESOURCE_EXHAUSTED, or a Compute 403 with a rate-limit reason.

Types

type BillingService

type BillingService interface {
	ListSKUs(ctx context.Context, serviceID string) (*cloudbilling.ListSkusResponse, error)
}

BillingService interface for billing operations (enables mocking).

type Client

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

Client handles GCP Compute Engine Committed Use Discounts.

func NewClient

func NewClient(projectID, region string, opts ...option.ClientOption) (*Client, error)

NewClient creates a new GCP Compute Engine client.

func (*Client) FilterRecommendationsForRecentCommitments

func (c *Client) FilterRecommendationsForRecentCommitments(recs []common.Recommendation, existing []common.Commitment) (passed, filtered []common.Recommendation, err error)

FilterRecommendationsForRecentCommitments defers the whole family: scalar vCPU subtraction cannot safely resize the independently committed memory amount.

func (*Client) GetExistingCommitments

func (c *Client) GetExistingCommitments(ctx context.Context) ([]common.Commitment, error)

GetExistingCommitments retrieves existing Compute Engine CUDs.

func (*Client) GetOfferingDetails

func (c *Client) GetOfferingDetails(ctx context.Context, rec common.Recommendation) (*common.OfferingDetails, error)

GetOfferingDetails retrieves CUD offering details from GCP Billing API.

func (*Client) GetRecommendations

func (c *Client) GetRecommendations(ctx context.Context, p *common.RecommendationParams) ([]common.Recommendation, error)

GetRecommendations gets CUD recommendations from GCP Recommender API.

func (*Client) GetRegion

func (c *Client) GetRegion() string

GetRegion returns the region.

func (*Client) GetServiceType

func (c *Client) GetServiceType() common.ServiceType

GetServiceType returns the service type.

func (*Client) PurchaseCommitment

func (c *Client) PurchaseCommitment(ctx context.Context, rec common.Recommendation, opts common.PurchaseOptions) (common.PurchaseResult, error)

PurchaseCommitment purchases a Compute Engine CUD.

func (*Client) SetBillingService

func (c *Client) SetBillingService(svc BillingService)

SetBillingService sets the billing service (for testing).

func (*Client) SetCommitmentsService

func (c *Client) SetCommitmentsService(svc CommitmentsService)

SetCommitmentsService sets the commitments service (for testing). An injected service is NOT page-capped (the cap lives in realCommitmentsService.List), so test doubles must bound themselves.

func (*Client) SetRecommenderClient

func (c *Client) SetRecommenderClient(client RecommenderClient)

SetRecommenderClient sets the recommender client (for testing).

type CommitmentsIterator

type CommitmentsIterator interface {
	Next() (*computepb.Commitment, error)
}

CommitmentsIterator interface for commitments iteration (enables mocking).

type CommitmentsOperation

type CommitmentsOperation interface {
	Wait(ctx context.Context, opts ...gax.CallOption) error
}

CommitmentsOperation interface for commitment operations (enables mocking).

type CommitmentsService

CommitmentsService interface for commitments operations (enables mocking).

type ComputePricing

type ComputePricing struct {
	Currency string

	// HourlyRate is the committed price per hour for the whole resource set.
	HourlyRate float64

	// CommitmentPrice is the committed price over the whole term.
	CommitmentPrice float64

	// OnDemandPrice is the on-demand price of the same resources over the term.
	OnDemandPrice float64

	SavingsPercentage float64
}

ComputePricing is the price of a commitment's resources, for one term.

type RecommenderClient

type RecommenderClient interface {
	ListRecommendations(ctx context.Context, req *recommenderpb.ListRecommendationsRequest) RecommenderIterator
	Close() error
}

RecommenderClient interface for recommender operations (enables mocking).

type RecommenderIterator

type RecommenderIterator interface {
	Next() (*recommenderpb.Recommendation, error)
}

RecommenderIterator interface for recommender iteration (enables mocking).

Jump to

Keyboard shortcuts

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