localpricing

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package localpricing provides a local SQLite-based pricing database for offline cost estimation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath returns the default path for the local pricing database.

func Exists

func Exists(path string) bool

Exists returns true if the pricing database file exists and has data.

func Sync

func Sync(opts SyncOptions) error

Sync downloads pricing data from cloud provider bulk APIs into the local store.

Types

type PriceEntry

type PriceEntry struct {
	USD         string `json:"USD"`
	Unit        string `json:"unit"`
	Description string `json:"description,omitempty"`
}

PriceEntry represents a single price dimension.

type QueryResult

type QueryResult struct {
	SKU        string
	Attributes map[string]string
	Prices     []PriceEntry
}

QueryResult represents a single product price result from the local database.

type Store

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

Store represents a local SQLite pricing database.

func Open

func Open(path string) (*Store, error)

Open opens or creates a local pricing database.

func (*Store) Close

func (s *Store) Close() error

Close closes the database.

func (*Store) GetMetadata

func (s *Store) GetMetadata(key string) (string, error)

GetMetadata gets a metadata value by key.

func (*Store) LookupPrice

func (s *Store) LookupPrice(vendor, service, region string, attrFilters map[string]string, priceUnit string) (gjson.Result, error)

LookupPrice queries the local pricing database for a product matching the given filters. Returns a gjson.Result in the same format as the remote GraphQL API response.

func (*Store) ProductCount

func (s *Store) ProductCount() (int, error)

ProductCount returns the total number of products in the database.

func (*Store) QueryProducts

func (s *Store) QueryProducts(vendor, service, region string, attributeFilters map[string]string) (*sql.Rows, error)

QueryProducts queries products matching the given filters.

func (*Store) SetMetadata

func (s *Store) SetMetadata(key, value string) error

SetMetadata sets a metadata key-value pair.

func (*Store) UpsertProduct

func (s *Store) UpsertProduct(vendor, region, service, productFamily, sku, attributes, prices string) error

UpsertProduct inserts or updates a product in the local database.

type SyncOptions

type SyncOptions struct {
	Providers  []string // aws, azure, google
	Store      *Store
	OnProgress func(provider string, count int)
}

SyncOptions configures which providers to sync.

Jump to

Keyboard shortcuts

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