utils

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildResourceGroupPortalURL

func BuildResourceGroupPortalURL(tenantID, subscriptionID, resourceGroupName string) string

BuildResourceGroupPortalURL builds the Azure Portal URL for a resource group

func BuildResourcePortalURL

func BuildResourcePortalURL(tenantID, resourceID string) string

BuildResourcePortalURL builds the Azure Portal URL for a resource Note: resourceID should start with / (e.g., /subscriptions/...)

func BuildSubscriptionPortalURL

func BuildSubscriptionPortalURL(tenantID, subscriptionID string) string

BuildSubscriptionPortalURL builds the Azure Portal URL for a subscription

func CloseLogger

func CloseLogger()

CloseLogger closes the log file

func CopyToClipboard

func CopyToClipboard(text string) error

CopyToClipboard copies text to the system clipboard

func GetLogPath

func GetLogPath() string

GetLogPath returns the current log file path (empty if logging disabled)

func InitLogger

func InitLogger() error

InitLogger initializes the debug logger if LAZYAZURE_DEBUG is set

func IsClipboardAvailable

func IsClipboardAvailable() bool

IsClipboardAvailable checks if the clipboard is available on the system

func IsDebugEnabled

func IsDebugEnabled() bool

IsDebugEnabled returns true if debug logging is enabled

func Log

func Log(format string, args ...interface{})

Log writes a log message with timestamp (no-op if debug logging is disabled)

func LogMetrics added in v0.4.0

func LogMetrics()

LogMetrics logs current metrics to the debug log

func OpenBrowser added in v0.2.0

func OpenBrowser(url string) error

OpenBrowser opens the given URL in the system's default browser This is cross-platform and works on Linux (xdg-open), macOS (open), and Windows (start)

func StartAPITimer added in v0.4.0

func StartAPITimer(operation string) func(error)

StartAPITimer starts a timer for an API call and returns a function to record the result Usage: defer StartAPITimer("operation")()

Types

type Metrics added in v0.4.0

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

Metrics provides performance tracking for cache operations and API calls

func GetMetrics added in v0.4.0

func GetMetrics() *Metrics

GetMetrics returns the global metrics instance

func (*Metrics) GetCacheHitRate added in v0.4.0

func (m *Metrics) GetCacheHitRate() float64

GetCacheHitRate returns the cache hit rate as a percentage

func (*Metrics) GetStats added in v0.4.0

func (m *Metrics) GetStats() MetricsSnapshot

GetStats returns a snapshot of current metrics

func (*Metrics) RecordAPICall added in v0.4.0

func (m *Metrics) RecordAPICall(duration time.Duration, err error)

RecordAPICall records an API call with its duration

func (*Metrics) RecordCacheHit added in v0.4.0

func (m *Metrics) RecordCacheHit()

RecordCacheHit records a cache hit

func (*Metrics) RecordCacheMiss added in v0.4.0

func (m *Metrics) RecordCacheMiss()

RecordCacheMiss records a cache miss

func (*Metrics) RecordEviction added in v0.4.0

func (m *Metrics) RecordEviction(count int)

RecordEviction records a cache eviction

func (*Metrics) Reset added in v0.4.0

func (m *Metrics) Reset()

Reset clears all metrics (useful for testing)

func (*Metrics) UpdateCacheSize added in v0.4.0

func (m *Metrics) UpdateCacheSize(rgCount, resCount, fullResCount int)

UpdateCacheSize updates the current cache size tracking

type MetricsSnapshot added in v0.4.0

type MetricsSnapshot struct {
	CacheHits          int64
	CacheMisses        int64
	CacheHitRate       float64
	Evictions          int64
	APICalls           int64
	APIErrors          int64
	AvgAPIDuration     time.Duration
	CurrentRGSize      int
	CurrentResSize     int
	CurrentFullResSize int
	MaxRGSize          int
	MaxResSize         int
	MaxFullResSize     int
}

MetricsSnapshot provides a point-in-time view of metrics

func (MetricsSnapshot) String added in v0.4.0

func (s MetricsSnapshot) String() string

String returns a formatted string representation of metrics

Jump to

Keyboard shortcuts

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